[Twisted-Python] Reactor Spinning?

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Mon May 24 13:53:32 MDT 2010


On 23 May, 03:42 pm, moxie at thoughtcrime.org wrote:
>
>Hey everyone, I've still been trying to track down this spin bug.  What
>I probably should have mentioned before is that these are SSL
>connections.  Looking through the 10.0 release code, I found the
>_sendCloseAlert method in tcp.py: http://pastebin.com/gZKxHtN5
>
>I feel like this is almost certainly the culprit.  Most suspiciously,
>there's an explicit empty write on pastebin-line 23:
>
>os.write(self.socket.fileno(), '')
>
>It looks to me like there's a code path where this write "succeeds," 
>the
>SSL socket reports that the connection is still not shut down, and then
>the transport is resumed via startWriting and startReading.  I assume
>that this then repeats for as long as that socket is up.
>This directly corresponds with the system calls I'm seeing (poll, empty
>write, poll, empty write...)
>
>I still don't have an entirely comprehensive grasp of whats' going on
>here, but while these efforts to "cleanly" shut down the SSL connection
>by exchanging alerts are heroic, I feel like it's much more common (and
>probably good enough) to just send an alert and immediately close the
>underlying socket.

It'd be great if you could attach a minimal example which demonstrates 
this behavior to a ticket in the issue tracker (threads on the mailing 
list usually lead to ignored issues).

It's probably also worth reporting your version of OpenSSL and 
pyOpenSSL, since that might be related.  I've not seen this kind of 
behavior before, which may just mean I'm running an older version of 
OpenSSL than you.

Jean-Paul




More information about the Twisted-Python mailing list