diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-09-29 12:19:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-29 12:19:11 (GMT) |
commit | 1c3e4691bb41fa070d6f4836cb03005123e53e4b (patch) | |
tree | 5faecc459a524f8159fe5350676b4b01d8d84108 /Lib/asyncio/unix_events.py | |
parent | 80dd66ac278ecbabbf843526e3a56f5031da9562 (diff) | |
download | cpython-1c3e4691bb41fa070d6f4836cb03005123e53e4b.zip cpython-1c3e4691bb41fa070d6f4836cb03005123e53e4b.tar.gz cpython-1c3e4691bb41fa070d6f4836cb03005123e53e4b.tar.bz2 |
bpo-38019: correctly handle pause/resume reading of closed asyncio unix pipe (GH-16472)
(cherry picked from commit 58498bc7178608b1ab031994ca09c43889ce3e76)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Diffstat (limited to 'Lib/asyncio/unix_events.py')
-rw-r--r-- | Lib/asyncio/unix_events.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py index a0fc996..7034fc2 100644 --- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -431,6 +431,7 @@ class _UnixReadPipeTransport(transports.ReadTransport): self._fileno = pipe.fileno() self._protocol = protocol self._closing = False + self._paused = False mode = os.fstat(self._fileno).st_mode if not (stat.S_ISFIFO(mode) or @@ -492,10 +493,20 @@ class _UnixReadPipeTransport(transports.ReadTransport): self._loop.call_soon(self._call_connection_lost, None) def pause_reading(self): + if self._closing or self._paused: + return + self._paused = True self._loop._remove_reader(self._fileno) + if self._loop.get_debug(): + logger.debug("%r pauses reading", self) def resume_reading(self): + if self._closing or not self._paused: + return + self._paused = False self._loop._add_reader(self._fileno, self._read_ready) + if self._loop.get_debug(): + logger.debug("%r resumes reading", self) def set_protocol(self, protocol): self._protocol = protocol |