issue #477: parent: make iter_read() log disconnect reason.
This commit is contained in:
parent
81f15028a7
commit
ffd46e9f1c
|
@ -455,20 +455,20 @@ def io_op(func, *args):
|
|||
signalled by :data:`errno.EPIPE`.
|
||||
|
||||
:returns:
|
||||
Tuple of `(return_value, disconnected)`, where `return_value` is the
|
||||
return value of `func(*args)`, and `disconnected` is :data:`True` if
|
||||
disconnection was detected, otherwise :data:`False`.
|
||||
Tuple of `(return_value, disconnect_reason)`, where `return_value` is
|
||||
the return value of `func(*args)`, and `disconnected` is an exception
|
||||
instance when disconnection was detected, otherwise :data:`None`.
|
||||
"""
|
||||
while True:
|
||||
try:
|
||||
return func(*args), False
|
||||
return func(*args), None
|
||||
except (select.error, OSError, IOError):
|
||||
e = sys.exc_info()[1]
|
||||
_vv and IOLOG.debug('io_op(%r) -> OSError: %s', func, e)
|
||||
if e.args[0] == errno.EINTR:
|
||||
continue
|
||||
if e.args[0] in (errno.EIO, errno.ECONNRESET, errno.EPIPE):
|
||||
return None, True
|
||||
return None, e
|
||||
raise
|
||||
|
||||
|
||||
|
|
|
@ -544,7 +544,8 @@ class IteratingRead(object):
|
|||
for fd in self.poller.poll(self.timeout):
|
||||
s, disconnected = mitogen.core.io_op(os.read, fd, 4096)
|
||||
if disconnected or not s:
|
||||
IOLOG.debug('iter_read(%r) -> disconnected', fd)
|
||||
LOG.debug('iter_read(%r) -> disconnected: %s',
|
||||
fd, disconnected)
|
||||
self.poller.stop_receive(fd)
|
||||
else:
|
||||
IOLOG.debug('iter_read(%r) -> %r', fd, s)
|
||||
|
|
Loading…
Reference in New Issue