[Twisted-Python] A non-blocking socket operation could not be completed immediately

Itamar Turner-Trauring (aka Shtull-Trauring) itamar at itamarst.org
Wed Nov 18 08:55:56 MST 2009


On Wed, 2009-11-18 at 06:03 -0800, Tommaso Mazzafico wrote:
> I tried this code:
> 
> -----------------------------------------
> from twisted.spread import pb
> from twisted.internet import reactor
> 
> class Echoer(pb.Root):
>    def remote_echo(self, s):
>       return s
> if __name__ == "__main__":
>    reactor.listenTCP(8001, pb.PBServerFactory(Echoer()))
>    reactor.run()
> -----------------------------------------
> 
> On Windows XP all is ok.
> On Windows 7 64 I receive this error message:
> 
> -----------------------------------------
> C:\Program Files (x86)\Python\lib\site-packages\twisted\spread\pb.py:30: DeprecationWarning: the md5 module is deprecated; use hashlib instead
>   import md5
> Traceback (most recent call last):
>   File "C:\Users\bob\Documents\Twisted\pbs.py", line 11, in <module>
>     reactor.listenTCP(8001, pb.PBServerFactory(Echoer()))
>   File "C:\Program Files (x86)\Python\lib\site-packages\twisted\internet\posixbase.py", line 356, in listenTCP
>     p.startListening()
>   File "C:\Program Files (x86)\Python\lib\site-packages\twisted\internet\tcp.py", line 862, in startListening
>     self._realPortNumber = skt.getsockname()[1]
>   File "<string>", line 1, in getsockname
> socket.error: [Errno 10035] A non-blocking socket operation could not be completed immediately
> -----------------------------------------
> 
> What can I do?

1. Please file a bug at http://twistedmatrix.com/ - include version of
Twisted, whether you have firewall of some sort, etc., so we can make
sure this gets fixed.

2. Try patching the code so it does:
    
    from twisted.internet.util import untilConcludes
    self._realPortNumber = untilConcludes(lambda: skt.getsockname()[1])

Does this fix it? If it does, add this info to the bug.

3. Another thing to try is the IOCP reactor.

-Itamar





More information about the Twisted-Python mailing list