simpy.rt
— Real-time simulation¶
Execution environment for events that synchronizes passing of time with the real-time (aka wall-clock time).
-
class
simpy.rt.
RealtimeEnvironment
(initial_time=0, factor=1.0, strict=True)¶ Execution environment for an event-based simulation which is synchronized with the real-time (also known as wall-clock time). A time step will take factor seconds of real time (one second by default). A step from
0
to3
with afactor=0.5
will, for example, take at least 1.5 seconds.The
step()
method will raise aRuntimeError
if a time step took too long to compute. This behaviour can be disabled by setting strict toFalse
.-
factor
= None¶ Scaling factor of the real-time.
-
strict
= None¶ Running mode of the environment.
step()
will raise aRuntimeError
if this is set toTrue
and the processing of events takes too long.
-
active_process
¶ The currently active process of the environment.
-
all_of
¶ alias of
AllOf
-
any_of
¶ alias of
AnyOf
-
event
¶ alias of
Event
-
exit
(value=None)¶ Stop the current process, optionally providing a
value
.This is a convenience function provided for Python versions prior to 3.3. From Python 3.3, you can instead use
return value
in a process.
-
now
¶ The current simulation time.
-
process
¶ alias of
Process
-
run
(until=None)¶ Executes
step()
until the given criterion until is met.- If it is
None
(which is the default), this method will return when there are no further events to be processed. - If it is an
Event
, the method will continue stepping until this event has been triggered and will return its value. Raises aRuntimeError
if there are no further events to be processed and the until event was not triggered. - If it is a number, the method will continue stepping until the environment’s time reaches until.
- If it is
-
schedule
(event, priority=1, delay=0)¶ Schedule an event with a given priority and a delay.
-
sync
()¶ Synchronize the internal time with the current wall-clock time.
This can be useful to prevent
step()
from raising an error if a lot of time passes between creating the RealtimeEnvironment and callingrun()
orstep()
.
-
timeout
¶ alias of
Timeout
-
step
()¶ Process the next event after enough real-time has passed for the event to happen.
The delay is scaled according to the real-time
factor
. Withstrict
mode enabled, aRuntimeError
will be raised, if the event is processed too slowly.
-