I have a pretty intensive chat socket server written in Twisted Python, I start it using internet.TCPServer with a factory and that factory references to a protocol object that handles all communications with the client.
How should I make sure a protocol instance completely destroys itself once a client has disconnected?
I've got a function named connectionLost that is fired up once a client disconnects and I try stopping all activity right there but I suspect some reactor stuff (like twisted.words instances) keep running for obsolete protocol instances.
What would be the best approach to handle this?
Thanks!
ok, for sorting out this issue I have set a
__del__
method in the protocol class and I am now logging protocol instances that have not been garbage collected within 1 minute from the time the client has disconnected.If anybody has any better solution I'll still be glad to hear about it but so far I have already fixed a few potential memory leaks using this log.
Thanks!