summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-10-14 22:55:37 +0200
committerVictor Stinner <victor.stinner@gmail.com>2014-10-14 22:55:37 +0200
commit85273eabd6ae3becfd588bc9728d62bdddc46acc (patch)
tree2b5bb2074c772fce7290170f7ca536b174812ffc
parentc061fb44df6d5d084bbf7d16aff9427f595d57c6 (diff)
downloadtrollius-85273eabd6ae3becfd588bc9728d62bdddc46acc.tar.gz
Enhance protocol representation
Add "closed" or "closing" to repr() of selector and proactor transports
-rw-r--r--asyncio/proactor_events.py8
-rw-r--r--asyncio/selector_events.py7
2 files changed, 13 insertions, 2 deletions
diff --git a/asyncio/proactor_events.py b/asyncio/proactor_events.py
index 0ad0656..7132300 100644
--- a/asyncio/proactor_events.py
+++ b/asyncio/proactor_events.py
@@ -42,7 +42,13 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin,
self._loop.call_soon(waiter._set_result_unless_cancelled, None)
def __repr__(self):
- info = [self.__class__.__name__, 'fd=%s' % self._sock.fileno()]
+ info = [self.__class__.__name__]
+ fd = self._sock.fileno()
+ if fd < 0:
+ info.append('closed')
+ elif self._closing:
+ info.append('closing')
+ info.append('fd=%s' % fd)
if self._read_fut is not None:
info.append('read=%s' % self._read_fut)
if self._write_fut is not None:
diff --git a/asyncio/selector_events.py b/asyncio/selector_events.py
index 33de92e..a55eff7 100644
--- a/asyncio/selector_events.py
+++ b/asyncio/selector_events.py
@@ -467,7 +467,12 @@ class _SelectorTransport(transports._FlowControlMixin,
self._server._attach()
def __repr__(self):
- info = [self.__class__.__name__, 'fd=%s' % self._sock_fd]
+ info = [self.__class__.__name__]
+ if self._sock is None:
+ info.append('closed')
+ elif self._closing:
+ info.append('closing')
+ info.append('fd=%s' % self._sock_fd)
# test if the transport was closed
if self._loop is not None:
polling = _test_selector_event(self._loop._selector,