Twisted tries to be as light as possible when it comes to a saved state. Just as bare factories do not watch their children, Protocolsthey know little about themselves. They are mainly callback bags.
connectionLost() - . :
from twisted.internet.protocol import Protocol
class StatefulProtocol(Protocol):
def __init__(self, factory):
self.connected = False
def connectionMade(self):
self.connected = True
def connectionLost(self, reason):
self.connected = False
: , , . , , , , . , Protocol, .