Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [sumo-user] Parallel processing

Hello,
subprocess.call() blocks until the started process has completed. This makes it unsuitable for starting sumo from a TraCI script. Instead subprocess.Popen or traci.start() should be used (take a look at the sourcecode of the start() method in sumo/tools/traci/__init__.py)

If you intend to use multiple traci connections from a single script then you must use traci.start() with a label to access the connections later.
You can also do
traci.start([...], label="a")
conn1 = traci._connections["a"]
traci.start([...], label="b")
conn2 = traci._connections["b"]

regards,
Jakob




2017-10-03 3:12 GMT+02:00 Luke Kakadukl <koseninc8@xxxxxxxxx>:
Hello,

I'm using Sumo with Traci in Python. 
I want to run multiple simulation in parallel.
I did find out that this is possible with: 
 subprocess.call(["sumo", "-c", "sim1.sumocfg", "--remote-port", "8813"])
 conn1 = traci.connect(8813)
 subprocess.call(["sumo", "-c", "sim2.sumocfg", "--remote-port", "8814"])
 conn2 = traci.connect(8814)
 conn1.simulationStep() # run 1 step for sim1
 conn2.simulationStep() # run 1 step for sim2
When I call subprocess.call(...)  simulation hangs at connecting. I did try to use several different port number but the result was the same. 
I'm using Windows machine and I also tried to run simulations with Firewall turned off, but this did not help.

Does someone know what could be the problem here?
I'm using latest SUMO nightly build.

Another question:
Is running every simulation in separate process with traci.start([...])  a correct way to do? 
[label is not specified, default value is used] 
By process I mean Process object from multiprocessing library.

Kind regards,
Luka

_______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/sumo-user



Back to the top