The issue appears to be that the DataDirectory is ~/.tor by default. It contains a lock file, which is why stem believes that Tor is already running.
You can change the DataDirectory like this:
process.launch_tor_with_config({…, 'DataDirectory': '~/.tor/custom1'})
I recommend that you run only one Tor instance, reducing complexity and resource use. The only reason I can think of why that you would want multiple instances is if you wanted to be sure that a different circuit is used for every connection. If you want that, you can simply set a different proxy password for every connection. As far as I know, Tor Browser still uses this technique to get a different circuit for every first party domain.
Here is a short example:
import itertools
from stem import process
import requests
with process.launch_tor_with_config({'ControlPort': '3421', 'SocksPort': '3420'}) as tor:
session = requests.session()
def receive(password):
proxies = {
'http': 'socks5://user:{}@localhost:3420'.format(password),
'https': 'socks5://user:{}@localhost:3420'.format(password)
}
return session.get('https://ipinfo.io', proxies=proxies)
print('== use 10 different circuits ==')
for response in map(receive, range(10)):
print(response.json()['ip'])
print()
print('== use 10 times same circuit (same password, same circuit) ==')
for response in map(receive, itertools.repeat('secret', 10)):
print(response.json()['ip'])
tor.terminate()
How many local concurrent Tor connections can I run?
I'm not sure if there is a limit for clients. There probably is a limit per guard node. This usually shouldn't be an issue though since a guard won't know anything about the connections you have made to the other guards. So, if a guard is randomly picked, you shouldn't be able hit the limit easily.
If you're running a relay, the limit is 2 per IP.