Just like this question, I don't understand what triggered means for a SimPy event. The only answer posted does not clarify it for me.
The docs say an event:
- might happen (not triggered),
- is going to happen (triggered) or
- has happened (processed).
I originally thought those corresponded to:
- event defined
- event yielded
- code in event completes execution
But then I found through experimentation that was wrong. I have not been able to create an example for which I can print p.triggered
and p.processed
for some process p
and have the first be True
and the second False
. They're always either both True
or both False
.
So my question is, can anyone give code of an example (ideally as simple as possible) for which there exists some moment of time that a process is triggered but not processed?
Ideally, it would include an explanation of "triggered" that matches the example.
This stuff is not clear, but my understanding is that when you use env.process() to convert one of your processes to a event, that event does not get triggered until you exit your process, not when it hits a yield. So if you write a process with a infinite loop, it will always be in that might happen (not triggered) state.
Events are not marked as processed until all events that can be triggered at a time x, are triggered. I think this allows for events to talk to each other and add callbacks, before callbacks get executed. I'm not sure what happens if a callback creates a new event that is immediately triggered.
here is some code to show the event flow
and here is the output I got