I'm trying to use pytransitions to implement retransmit logic from an initialization state. The summary is that during the init state if the other party isn't responding after 1 second resend the packet. This is very similar to what I see here: https://github.com/pytransitions/transitions/pull/461
I tried this patch, and even though I see the timeouts/failures happening, my callback is only called the first time. This is true with before/after and on_enter/exit. No matter what I've tried, I can't get the retransmit to occur again. Any ideas?
Even though this question is a bit dated I'd like to post an answer since
Retrystates have been added totransitionsin release0.9.Retryitself will only count how often a state has been re-entered meaning that the counter will increase when transition source and destination are equal and reset otherwise. It's entirely passive and need another mean to trigger events. TheTimeoutstate extension is commonly used in addition toRetryto achieve this. In the example below a state machine is decorated withRetryandTimeoutstate extensions which allows to use a couple of keywords for state definitions:timeout- time in seconds before a timeout is triggered after a state has been enteredon_timeout- the callback(s) called whentimeoutwas triggeredretries- the number of retries before failure callbacks are called when a state is re-enteredon_failure- the callback(s) called when the re-entrance counter reachesretriesThe example will re-enter
pingingunless a randomly generated number between 0 and 1 is larger than 0.8. This can be interpreted as a server that roughly answers only every fifth request. When you execute the example the retries required to reach 'initialized' can vary or even fail whenretriesare reached.