summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorGuido van Rossum <guido@dropbox.com>2013-11-16 00:51:48 (GMT)
committerGuido van Rossum <guido@dropbox.com>2013-11-16 00:51:48 (GMT)
commit2335de7a2082f05c43977996533cee93384ff7a9 (patch)
treef8b36a6d9ec06849a7365d52813489e1fa56bdcd /Lib/asyncio
parent6f87a08aa70887026f92694ab1bfb9bccf0d7504 (diff)
downloadcpython-2335de7a2082f05c43977996533cee93384ff7a9.zip
cpython-2335de7a2082f05c43977996533cee93384ff7a9.tar.gz
cpython-2335de7a2082f05c43977996533cee93384ff7a9.tar.bz2
asyncio: Replace connection_refused() with error_received().
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/protocols.py12
-rw-r--r--Lib/asyncio/selector_events.py17
2 files changed, 13 insertions, 16 deletions
diff --git a/Lib/asyncio/protocols.py b/Lib/asyncio/protocols.py
index d3a8685..eb94fb6 100644
--- a/Lib/asyncio/protocols.py
+++ b/Lib/asyncio/protocols.py
@@ -100,15 +100,18 @@ class DatagramProtocol(BaseProtocol):
def datagram_received(self, data, addr):
"""Called when some datagram is received."""
- def connection_refused(self, exc):
- """Connection is refused."""
+ def error_received(self, exc):
+ """Called when a send or receive operation raises an OSError.
+
+ (Other than BlockingIOError or InterruptedError.)
+ """
class SubprocessProtocol(BaseProtocol):
"""ABC representing a protocol for subprocess calls."""
def pipe_data_received(self, fd, data):
- """Called when subprocess write a data into stdout/stderr pipes.
+ """Called when the subprocess writes data into stdout/stderr pipe.
fd is int file dascriptor.
data is bytes object.
@@ -122,5 +125,4 @@ class SubprocessProtocol(BaseProtocol):
"""
def process_exited(self):
- """Called when subprocess has exited.
- """
+ """Called when subprocess has exited."""
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index 3bad198..3efa4d2 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -771,6 +771,8 @@ class _SelectorDatagramTransport(_SelectorTransport):
data, addr = self._sock.recvfrom(self.max_size)
except (BlockingIOError, InterruptedError):
pass
+ except OSError as exc:
+ self._protocol.error_received(exc)
except Exception as exc:
self._fatal_error(exc)
else:
@@ -800,9 +802,8 @@ class _SelectorDatagramTransport(_SelectorTransport):
return
except (BlockingIOError, InterruptedError):
self._loop.add_writer(self._sock_fd, self._sendto_ready)
- except ConnectionRefusedError as exc:
- if self._address:
- self._fatal_error(exc)
+ except OSError as exc:
+ self._protocol.error_received(exc)
return
except Exception as exc:
self._fatal_error(exc)
@@ -822,9 +823,8 @@ class _SelectorDatagramTransport(_SelectorTransport):
except (BlockingIOError, InterruptedError):
self._buffer.appendleft((data, addr)) # Try again later.
break
- except ConnectionRefusedError as exc:
- if self._address:
- self._fatal_error(exc)
+ except OSError as exc:
+ self._protocol.error_received(exc)
return
except Exception as exc:
self._fatal_error(exc)
@@ -835,8 +835,3 @@ class _SelectorDatagramTransport(_SelectorTransport):
self._loop.remove_writer(self._sock_fd)
if self._closing:
self._call_connection_lost(None)
-
- def _force_close(self, exc):
- if self._address and isinstance(exc, ConnectionRefusedError):
- self._protocol.connection_refused(exc)
- super()._force_close(exc)