[Twisted-Python] Using twisted with logging.handlers.sockethandler

Atilla theatilla at gmail.com
Tue Nov 20 08:30:50 EST 2007


Correct me if I'm not explaining it correct, but:

dataReceived makes no guarantees how mcuh data you'll get - it depends
on many factors, buffers on the sending and the receiving side, the
size of TCP chunks (if it's TCP), etc.  As stated in the docstrings
for the method - you should make sure your methods works for chunks of
various size, down to the minimum that can come.

What I do is - I model it as a small state-machine that keeps a local
buffer of the data (with an upper bound), trying to construct a
message that's meaningful for my protocol, and when it does - it calls
a method that expects a full protocol packet, that I handle from there
on.

For a good example you can take a look at the lineReceived
implementation, from the actual twisted package. The code and the
docstrings are amazingly useful that way.




More information about the Twisted-Python mailing list