[Twisted-Python] protocol and transport question

Luca Politti luca at unipex.it
Tue Aug 21 05:02:34 MDT 2007


Hi all,
I have a problem with a simple client/server communication: I have a
server that send the data through "transport" (my class inherit from
twisted.internet.protocol.Protocol), every 0.4 seconds. On the client
(that now, for test propose are on the same machine) some time I receive
two messages concatenated from the server like it send on the same time.
Other times, I receive it correctly (in different moments).
I tried to debug this situations with print some messages, and I see
that twisted sometimes wait "a time" before send data through the
channel:

on the server, on twisted.internet.tcp.Connection on writeSomeData I add:
print "CCCCCCCCCCCCCCCCC", repr(data), time.time()
try:
     # Limit length of buffer to try to send, because some OSes are too
....

on my code:
print "BBBBBBBBBBBBBBBBBBB", repr(msg), time.time()
self.transport.write(str(msg))

and I see (then it's wrong):
BBBBBBBBBBBBBBBBBBB '230 XXXXXXXXX\n' 1187693294.84
BBBBBBBBBBBBBBBBBBB '235 XXXXXXXXX 144\n' 1187693295.28
CCCCCCCCCCCCCCCCC '230 XXXXXXXXX \n235 XXXXXXXXX 144\n' 1187693295.28

and when it's right:
BBBBBBBBBBBBBBBBBBB '230 XXXXXXXXX \n' 1187693282.89
CCCCCCCCCCCCCCCCC '230 XXXXXXXXX \n' 1187693283.06
BBBBBBBBBBBBBBBBBBB '235 XXXXXXXXX 143\n' 1187693283.28
CCCCCCCCCCCCCCCCC '235 XXXXXXXXX 143\n' 1187693283.28


How solve it? Is there a method for say to twisted (transport) to not
wait to send the data? (flush the buffer?)

Thanks a lot!

Luca




More information about the Twisted-Python mailing list