[Twisted-Python] Question about writing a server that accepts multiple clients with independent processing

Phil Mayers p.mayers at imperial.ac.uk
Thu Feb 21 05:32:32 EST 2008

> Thank you Stephan, ok, but is an instance of a protocol created for 
> every connection? I tried to add data received  by the protocol to a 

For TCP connections, assuming everything is coded correctly, yes.

> list, and if I get multiple connections that list is filled with all the 
> connection's data, like if only one instance existed.

You didn't by any chance use a class variable did you e.g.:

class foo(...):
   my_data = []
   def dataReceived(self, data):

...is wrong. "my_data" is shared by all instances of the class and is 
mutable. You'll need to create instance variables, usually (I believe) 
as part of the factory process.

If you can write a minimal example showing the problem, someone can 
probably tell you what you're doing wrong.

More information about the Twisted-Python mailing list