[Twisted-Python] a possible solution for ticket 5562

gelin yan dynamicgl at gmail.com
Sat Oct 20 11:29:10 EDT 2012

Hi All

  A few months ago, I reported a bug about IOCP. Last night I spent several
hours on its implementation and finally found out a possible solution for

  when sending some small chunks data continuously, the buffer will pile
them up and send to IOCP; however there is a SEND_LIMIT (128K) that means
only 128K will be handled. Now the problem is when we try to trigger the
next writing, IOCP will raise ERROR_IO_PENDING immediately and then
connection Lost.

  So I got a idea: if the size of data is larger than SEND_LIMIT, we can
wait a little bit time for the next writing instead of do it immediately.

in twisted\internet\iocpreactor\abstract.py there is a method

def _cbWrite(self, rc, bytes, evt):
        if self._handleWrite(rc, bytes, evt):

now I modified a bit,

def _cbWrite(self, rc, bytes, evt):
        if self._handleWrite(rc, bytes, evt):
            if len(evt.buff) < self.SEND_LIMIT:

0.8 is a silly trial but I have no idea what is the right number for this
place. After this modification, previous problematic scripts can pass.

Maybe the better solution is to find a way to poll the complete port status
when read/write will be recovered from IO PENDING. Simply wait a little is


gelin yan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20121020/d9ec2bc7/attachment.htm 

More information about the Twisted-Python mailing list