On Wednesday, 5 February 2020 08:48:41 GMT Colin Dunklau wrote:
> I wasn't able to find an example in Twisted of an implicit state
> machine. Maybe someone else has a concrete example somewhere?

There is an example of an explicit state machine in the twisted code
for http chunked transfer encoding.

Its in https://github.com/twisted/twisted/blob/trunk/src/twisted/web/
http.py#L1779

If there is code that assumes that it can react directly off of the events 
from a framework like twisted. When events happen in an unexpected
sequence you can end with errors. For example you can get a connectionLost
event at any time.

If you have a state machine it is easy to know what the clean actions will be.
But if there is no explicit state the code may not have the information it
needs to handle the connectionLost in an appropriate ways.

The situation with states and events only gets more complex when there
are deferred's that run after a connectionLost event and assume a connect
is still live. If such a deferred can check an explicit state it is far easier
to make the code work appropriately.

Barry



_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

Reply via email to