[Twisted-Python] does setTcpNoDelay() not work?
gabriel.rossetti at arimaz.com
Mon Aug 11 14:18:43 EDT 2008
Jean-Paul Calderone wrote:
> On Mon, 11 Aug 2008 19:13:56 +0200, Gabriel Rossetti
> <gabriel.rossetti at arimaz.com> wrote:
>> Gabriel Rossetti wrote:
>>> I'm needing to send small packets to update a progress bar. My
>>> update msgs were all being sent in big packets, so I tried setting
>>> setTcpNoDelay() in connectionMade() but it doesn't change anything,
>>> is it broken?
>>> Thank you,
>> I an using code that I wrote using threads.deferToThread(), I
>> wondered if it was blocking the reactor maybe, so I tried just using
>> a plain deferToThread() call. Here's the code (without all the
>> protocol stuff, it's executed when data come in.
>> def loop(self):
>> import time
>> m = utils.createMessage("toto", "hello")
>> print "Sending %s" % m.toXml()
>> print "Sent!"
>> the TCP no delay option is turned on like I said before, the weird
>> thing is that I have the same thing, all my msgs get sent in big
>> blocks. Either the TCP no delay doesn't work, or the reactor is
>> getting tied up. I don' t get it since I'm running the blocking code
>> in a thread, the reactor should have nothing to do.
> Since you didn't include the definition of `sendMessage´, it's hard to
> what's really going on here. However, my guess is that you're calling
> transport.write method in a non-reactor thread, which is not allowed.
> If this isn't the case, including a full, minimal example in your next
> message would be a good idea. :)
Yes, self.sendMessage() calls transport.write. So there's no way of
sending msgs from a non-reactor thread, even if it has a reference to
More information about the Twisted-Python