fix tests and added is_reading() to unixReadPipeTransport

This commit is contained in:
itay azolay 2020-01-10 00:37:05 +02:00
parent a16f4d380c
commit c4b3444f9b
2 changed files with 6 additions and 2 deletions

View File

@ -773,7 +773,7 @@ class _SelectorSocketTransport(_SelectorTransport):
return not self._paused and not self._closing return not self._paused and not self._closing
def pause_reading(self): def pause_reading(self):
if self._closing or self._paused: if not self.is_reading():
return return
self._paused = True self._paused = True
self._loop._remove_reader(self._sock_fd) self._loop._remove_reader(self._sock_fd)

View File

@ -466,11 +466,15 @@ class _UnixReadPipeTransport(transports.ReadTransport):
# only wake up the waiter when connection_made() has been called # only wake up the waiter when connection_made() has been called
self._loop.call_soon(futures._set_result_unless_cancelled, self._loop.call_soon(futures._set_result_unless_cancelled,
waiter, None) waiter, None)
def _add_reader(self, fd, callback): def _add_reader(self, fd, callback):
if not self.is_reading(): if not self.is_reading():
return return
self._loop._add_reader(fd, callback) self._loop._add_reader(fd, callback)
def is_reading(self):
return not self._paused and not self._closing
def __repr__(self): def __repr__(self):
info = [self.__class__.__name__] info = [self.__class__.__name__]
if self._pipe is None: if self._pipe is None:
@ -511,7 +515,7 @@ class _UnixReadPipeTransport(transports.ReadTransport):
self._loop.call_soon(self._call_connection_lost, None) self._loop.call_soon(self._call_connection_lost, None)
def pause_reading(self): def pause_reading(self):
if self._closing or self._paused: if not self.is_reading():
return return
self._paused = True self._paused = True
self._loop._remove_reader(self._fileno) self._loop._remove_reader(self._fileno)