summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/unix_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-02-19 00:40:41 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-02-19 00:40:41 (GMT)
commit0ee29c2c7fbc7e1b10e153b0cb59d2270347d4f3 (patch)
treea12bfe6a1d42c325134ca0a245cce8e96aa9a641 /Lib/asyncio/unix_events.py
parent3cb9914488d2d5c95a1b688a68302f5fa2e914ad (diff)
downloadcpython-0ee29c2c7fbc7e1b10e153b0cb59d2270347d4f3.zip
cpython-0ee29c2c7fbc7e1b10e153b0cb59d2270347d4f3.tar.gz
cpython-0ee29c2c7fbc7e1b10e153b0cb59d2270347d4f3.tar.bz2
asyncio, Tulip issue 139: Improve error messages on "fatal errors"
Mention if the error was caused by a read or a write, and be more specific on the object (ex: "pipe transport" instead of "transport").
Diffstat (limited to 'Lib/asyncio/unix_events.py')
-rw-r--r--Lib/asyncio/unix_events.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index 748452c..3a2fd18 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -271,7 +271,7 @@ class _UnixReadPipeTransport(transports.ReadTransport):
except (BlockingIOError, InterruptedError):
pass
except OSError as exc:
- self._fatal_error(exc)
+ self._fatal_error(exc, 'Fatal read error on pipe transport')
else:
if data:
self._protocol.data_received(data)
@@ -291,11 +291,11 @@ class _UnixReadPipeTransport(transports.ReadTransport):
if not self._closing:
self._close(None)
- def _fatal_error(self, exc):
+ def _fatal_error(self, exc, message='Fatal error on pipe transport'):
# should be called by exception handler only
if not (isinstance(exc, OSError) and exc.errno == errno.EIO):
self._loop.call_exception_handler({
- 'message': 'Fatal transport error',
+ 'message': message,
'exception': exc,
'transport': self,
'protocol': self._protocol,
@@ -381,7 +381,7 @@ class _UnixWritePipeTransport(transports._FlowControlMixin,
n = 0
except Exception as exc:
self._conn_lost += 1
- self._fatal_error(exc)
+ self._fatal_error(exc, 'Fatal write error on pipe transport')
return
if n == len(data):
return
@@ -406,7 +406,7 @@ class _UnixWritePipeTransport(transports._FlowControlMixin,
# Remove writer here, _fatal_error() doesn't it
# because _buffer is empty.
self._loop.remove_writer(self._fileno)
- self._fatal_error(exc)
+ self._fatal_error(exc, 'Fatal write error on pipe transport')
else:
if n == len(data):
self._loop.remove_writer(self._fileno)
@@ -443,11 +443,11 @@ class _UnixWritePipeTransport(transports._FlowControlMixin,
def abort(self):
self._close(None)
- def _fatal_error(self, exc):
+ def _fatal_error(self, exc, message='Fatal error on pipe transport'):
# should be called by exception handler only
if not isinstance(exc, (BrokenPipeError, ConnectionResetError)):
self._loop.call_exception_handler({
- 'message': 'Fatal transport error',
+ 'message': message,
'exception': exc,
'transport': self,
'protocol': self._protocol,