python / asyncio

asyncio historical repository
https://docs.python.org/3/library/asyncio.html
1.04k stars 177 forks source link

errno EHOSTUNREACH forces loop to close #380

Closed Marco-Sulla closed 8 years ago

Marco-Sulla commented 8 years ago

In asyncio/selector_events.py:

    def _read_ready(self):
        try:
            data = self._sock.recv(self.max_size)
        except (BlockingIOError, InterruptedError):
            pass
        except Exception as exc:
            self._fatal_error(exc, 'Fatal read error on socket transport')

errno.EHOSTUNREACH is uncatched. _fatal_error does not manage it too, and forces the loop connection to close.

Is this intended? This causes my aiohttp server to shutdown on a network problem.

gvanrossum commented 8 years ago

Sounds to me this is intended -- once you get an error the connection is busted and there's nothing you can do about it anyway (given that this code is used only for TCP, not for UDP).

Marco-Sulla commented 8 years ago

EINTR (InterruptedError) is managed, I don't know if you can manage EHOSTUNREACH similarly. Yes, the protocol is TCP.

EDIT: probably not. I searched a little and also node.js does not manage EHOSTUNREACH by default. Sorry for bothering.

Martiusweb commented 8 years ago

EINTR happens when a signal interrupts a call, meaning that the call should be tried again after the interruption is handled. This error is independent of what the syscall does and is not fatal. AFAIK, with Python 3.5 and later, this exception is not raised anymore and handled at a lower level. EHOSTUNREACH is a fatal error related to the network operation you are trying to do, which will never be able to complete. Unfortunately, there is nothing else that can be done here.

2016-07-20 15:12 GMT+02:00 MarcoSulla notifications@github.com:

EINTR is managed, I don't know if you can manage EHOSTUNREACH similarly. Yes, the protocol is TCP.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/python/asyncio/issues/380#issuecomment-233944426, or mute the thread https://github.com/notifications/unsubscribe-auth/AAL7GDDcAHHv9xULkJ_vxLEypT4zSNu9ks5qXh64gaJpZM4JP0oU .

Martin http://www.martiusweb.net Richard www.martiusweb.net