SimPy compatibility API Reference

The usim.py package recreates the v4 API of the simpy package. It serves as a drop-in replacement for SimPy in order to gradually integrate and migrate simulations to μSim. For use in an existing SimPy simulation, it is sufficient to import usim.py in place of simpy.

# load the compatibility layer in place of simpy
import usim.py as simpy

The usim.py package itself provides direct access to the most relevant objects. However, they can be fetched from their respective submodules as well.

Environments (usim.py.core)

Environment(initial_time=0)

Execution environment for a simulation

RealtimeEnvironment(...)

Not supported by μSim

Hint

μSim simulations are started by usim.run().

Events (usim.py.events)

Event(env)

Event that is manually triggered,

Timeout(env, delay, value=None)

Event that triggers after a delay

Process(env, generator)

Active event that processes an event-yielding generator

AllOf(env, events)

Event that triggers once all events succeed

AnyOf(env, events)

Event that triggers once any events succeed

Interrupt(cause)

Exception to interrupt() a Process

Hint

μSim simulations can await events and may succeed() and fail() them.

Resources (usim.py.resources)

Resource(env, capacity=1)

Resource with a fixed capacity of usage slots

PriorityResource(env, capacity=1)

Resource with a fixed capacity of usage slots granted with priorities

PreemptiveResource(env, capacity=1)

Resource with a fixed capacity of usage slots preempted with priorities

Container(env, capacity=inf, init=0)

Resource with a fixed capacity of continuous, indistinguishable content

Store(env, capacity=inf)

Resource with a fixed capacity of slots for storing arbitrary objects

PriorityStore(env, capacity=inf)

Resource with capacity slots for storing objects in priority order.

PriorityItem(priority, item)

Wrap an arbitrary item with an orderable priority.

FilterStore(env, capacity=inf)

Resource with capacity slots for storing arbitrary objects supporting filtered get requests.

Exceptions (usim.py.exceptions)

SimPyException()

Base case for all non-internal exceptions

Interrupt(cause)

Exception to interrupt() a Process

StopProcess(value)

Exception to exit() a Process

Detailed Topics