Now I learn the simpy
library of python.
Could you explain me why bitwise-or
is used in this example. Why we can't use simple or
statement.
results = yield req | env.timeout(patience)
From SimPy's documentation of Core Event Types
This class also implements and() (&) and or() (|). If you concatenate two events using one of these operators, a Condition event is generated that lets you wait for both or one of them.
This implies that req
and env.timeout(patience)
are both events and we'll yield the first one that occurs. I.e.
results = yield (req | env.timeout(patience))
To answer your original question, it appears you can use or
instead but that might not make what's really going on any clearer and lead to editing errors if one assumes it's a regular old or
.