From c4b3444f9bb487e951266bbc8e97a1d82ab7dd07 Mon Sep 17 00:00:00 2001 From: itay azolay Date: Fri, 10 Jan 2020 00:37:05 +0200 Subject: [PATCH] fix tests and added is_reading() to unixReadPipeTransport --- Lib/asyncio/selector_events.py | 2 +- Lib/asyncio/unix_events.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py index 0419893cd1a..6413ce0de1b 100644 --- a/Lib/asyncio/selector_events.py +++ b/Lib/asyncio/selector_events.py @@ -773,7 +773,7 @@ class _SelectorSocketTransport(_SelectorTransport): return not self._paused and not self._closing def pause_reading(self): - if self._closing or self._paused: + if not self.is_reading(): return self._paused = True self._loop._remove_reader(self._sock_fd) diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py index ef8909e47ad..b58e2b39c58 100644 --- a/Lib/asyncio/unix_events.py +++ b/Lib/asyncio/unix_events.py @@ -466,11 +466,15 @@ class _UnixReadPipeTransport(transports.ReadTransport): # only wake up the waiter when connection_made() has been called self._loop.call_soon(futures._set_result_unless_cancelled, waiter, None) + def _add_reader(self, fd, callback): if not self.is_reading(): return self._loop._add_reader(fd, callback) + def is_reading(self): + return not self._paused and not self._closing + def __repr__(self): info = [self.__class__.__name__] if self._pipe is None: @@ -511,7 +515,7 @@ class _UnixReadPipeTransport(transports.ReadTransport): self._loop.call_soon(self._call_connection_lost, None) def pause_reading(self): - if self._closing or self._paused: + if not self.is_reading(): return self._paused = True self._loop._remove_reader(self._fileno)