[Twisted-Python] Why classes in twisted.protocols.basic use "static member" to store states?
littlesweetmelon at gmail.com
Thu Mar 29 23:38:35 EDT 2007
I'm a newbie. After went through the source code in
twisted.protocols.basic, I found it's really strange that all classes
in twisted.protocols.basic use "static member" to store states.
Take class StatefulStringProtocol as the example. Some Factory
will creates a group of StatefulStringProtocol instances which share
the static member "state". But why all instances MUST have the same
state? In my opinion, instance A may be in the "handshaking" state,
while instance B may be in the "data sending" state. The static member
can not represent this case.
Therefore, I think protocols should use "member variable" rather
that "static member":
self.state = 'init'
Could you plz give me some clue? I am a little confused. Most
possibly, I misunderstanding the design about protocols-factory.
More information about the Twisted-Python