| 1 |
""" |
| 2 |
Example for SimPy with Parallel Python. |
| 3 |
""" |
| 4 |
|
| 5 |
import PPExampleProcess |
| 6 |
from SimPy.Simulation import * |
| 7 |
import pp |
| 8 |
|
| 9 |
|
| 10 |
def runSimulation(jobNum, numCars): |
| 11 |
sim = SimPy.Simulation.Simulation() |
| 12 |
cars = [] |
| 13 |
for i in range(numCars): |
| 14 |
car = PPExampleProcess.Car(sim, i * jobNum + i) |
| 15 |
sim.activate(car, car.run(), at = 0) |
| 16 |
cars.append(car) |
| 17 |
sim.simulate(until = 30) |
| 18 |
|
| 19 |
|
| 20 |
server = pp.Server(ppservers = ()) |
| 21 |
for i in range(4): |
| 22 |
job = server.submit( |
| 23 |
runSimulation, |
| 24 |
(i, 2), |
| 25 |
(), |
| 26 |
('SimPy.Simulation', 'PPExampleProcess')) |
| 27 |
job() |
| 28 |
|