/usr/lib/python3/dist-packages/SimPy/SimulationStep.py is in python3-simpy 2.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # coding=utf-8
"""
SimulationStep supports stepping through SimPy simulation event - by - event.
Based on generators.
"""
from SimPy.Simulation import *
_step = False
class SimulationStep(Simulation):
def __init__(self):
Simulation.__init__(self)
self._step = False
def initialize(self):
Simulation.initialize(self)
self._step = False
def startStepping(self):
"""Application function to start stepping through simulation."""
self._step = True
def stopStepping(self):
"""Application function to stop stepping through simulation."""
self._step = False
def step(self):
Simulation.step(self)
if self._step: self.callback()
def simulate(self, callback=lambda: None, until=0):
"""
Simulates until simulation time reaches ``until``. After processing each
event, ``callback`` will be invoked if stepping has been enabled with
:meth:`~SimPy.SimulationStep.startStepping`.
"""
self.callback = callback
return Simulation.simulate(self, until)
# For backward compatibility
Globals.sim = SimulationStep()
def startStepping():
Globals.sim.startStepping()
def stopStepping():
Globals.sim.stopStepping()
peek = Globals.sim.peek
step = Globals.sim.step
allMonitors = Globals.sim.allMonitors
allTallies = Globals.sim.allTallies
def simulate(callback = lambda :None, until = 0):
return Globals.sim.simulate(callback = callback, until = until)
# End backward compatibility
|