diff options
Diffstat (limited to 'Lib/asyncio')
-rw-r--r-- | Lib/asyncio/base_subprocess.py | 3 | ||||
-rw-r--r-- | Lib/asyncio/proactor_events.py | 3 | ||||
-rw-r--r-- | Lib/asyncio/selector_events.py | 3 | ||||
-rw-r--r-- | Lib/asyncio/sslproto.py | 3 | ||||
-rw-r--r-- | Lib/asyncio/streams.py | 2 | ||||
-rw-r--r-- | Lib/asyncio/transports.py | 4 | ||||
-rw-r--r-- | Lib/asyncio/unix_events.py | 6 |
7 files changed, 23 insertions, 1 deletions
diff --git a/Lib/asyncio/base_subprocess.py b/Lib/asyncio/base_subprocess.py index 6851cd2b88..73425d9bbc 100644 --- a/Lib/asyncio/base_subprocess.py +++ b/Lib/asyncio/base_subprocess.py @@ -87,6 +87,9 @@ class BaseSubprocessTransport(transports.SubprocessTransport): def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs): raise NotImplementedError + def is_closing(self): + return self._closed + def close(self): if self._closed: return diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py index abe4c129c9..9c514c8345 100644 --- a/Lib/asyncio/proactor_events.py +++ b/Lib/asyncio/proactor_events.py @@ -65,6 +65,9 @@ class _ProactorBasePipeTransport(transports._FlowControlMixin, def _set_extra(self, sock): self._extra['pipe'] = sock + def is_closing(self): + return self._closing + def close(self): if self._closing: return diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index 0060912219..236f7b36a8 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -556,6 +556,9 @@ class _SelectorTransport(transports._FlowControlMixin, def abort(self): self._force_close(None) + def is_closing(self): + return self._closing + def close(self): if self._closing: return diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py index 9e08b6f88b..dde980b68f 100644 --- a/Lib/asyncio/sslproto.py +++ b/Lib/asyncio/sslproto.py @@ -304,6 +304,9 @@ class _SSLProtocolTransport(transports._FlowControlMixin, """Get optional transport information.""" return self._ssl_protocol._get_extra_info(name, default) + def is_closing(self): + return self._closed + def close(self): """Close the transport. diff --git a/Lib/asyncio/streams.py b/Lib/asyncio/streams.py index 64d10203d2..6b5e96aea2 100644 --- a/Lib/asyncio/streams.py +++ b/Lib/asyncio/streams.py @@ -302,7 +302,7 @@ class StreamWriter: if exc is not None: raise exc if self._transport is not None: - if self._transport._closing: + if self._transport.is_closing(): # Yield to the event loop so connection_lost() may be # called. Without this, _drain_helper() would return # immediately, and code that calls diff --git a/Lib/asyncio/transports.py b/Lib/asyncio/transports.py index 03099e3e54..9a6d9197d9 100644 --- a/Lib/asyncio/transports.py +++ b/Lib/asyncio/transports.py @@ -19,6 +19,10 @@ class BaseTransport: """Get optional transport information.""" return self._extra.get(name, default) + def is_closing(self): + """Return True if the transport is closing or closed.""" + raise NotImplementedError + def close(self): """Close the transport. diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py index bf3b0844fd..f75e89f317 100644 --- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -364,6 +364,9 @@ class _UnixReadPipeTransport(transports.ReadTransport): def resume_reading(self): self._loop.add_reader(self._fileno, self._read_ready) + def is_closing(self): + return self._closing + def close(self): if not self._closing: self._close(None) @@ -548,6 +551,9 @@ class _UnixWritePipeTransport(transports._FlowControlMixin, self._loop.remove_reader(self._fileno) self._loop.call_soon(self._call_connection_lost, None) + def is_closing(self): + return self._closing + def close(self): if self._pipe is not None and not self._closing: # write_eof is all what we needed to close the write pipe |