[Twisted-Python] Handling exceptions in twisted.internet.udp?

Attila Nagy bra at fsn.hu
Mon Feb 8 14:17:57 EST 2010

exarkun at twistedmatrix.com wrote:
>> [snip]
>> "/usr/lib64/python2.6/site-packages/Twisted-9.0.0_r27775-py2.6-linux- 
>> x86_64.egg/twisted/internet/udp.py",
>> line 109, in doRead
>>            data, addr = self.socket.recvfrom(self.maxPacketSize)
>>        socket.error: [Errno 113] No route to host
>> I wonder what is the preferred way of achieving that the socket will be
>> write()-able and kept open regardless what ICMP or other sending or
>> receiving error occurs?
> It seems like udp.py should be handling EHOSTUNREACH (and probably 
> several more errors that it also misses currently).  There's already a 
> `connectionRefused` callback which could be invoked to handle these 
> cases.
> This seems pretty related to another open ticket:
>   http://twistedmatrix.com/trac/ticket/3396
> Aside from monkey-patching the doRead method, I don't see a way for an 
> application to handle this one.
Currently the page is inaccessible (TimeoutError), but that doesn't 
sound good. :(
I will work around this by modifying udp.py, that's easier in this 
moment than overloading half of twisted. :)
> Development has started on fixing each of these issues.  The latter 
> seems to even have been reviewed and is now waiting for someone to 
> address the review feedback.
OK, let's hope that these will be fixed soon.


More information about the Twisted-Python mailing list