mirror of
https://github.com/python/cpython.git
synced 2025-08-28 04:35:02 +00:00
bpo-38019: correctly handle pause/resume reading of closed asyncio unix pipe (GH-16472)
This commit is contained in:
parent
9a7d951950
commit
58498bc717
3 changed files with 39 additions and 0 deletions
|
@ -445,6 +445,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
|
||||
|
@ -506,10 +507,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue