Skip to content

Commit 31da431

Browse files
committed
asyncio: sync with Tulip
* Fix a race condition in BaseSubprocessTransport._try_finish(). If the process exited before the _post_init() method was called, scheduling the call to _call_connection_lost() with call_soon() is wrong: connection_made() must be called before connection_lost(). Reuse the BaseSubprocessTransport._call() method to schedule the call to _call_connection_lost() to ensure that connection_made() and connection_lost() are called in the correct order. * Add repr(PipeHandle) * Fix typo
1 parent d8a2d75 commit 31da431

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Lib/asyncio/base_subprocess.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def _try_finish(self):
153153
if all(p is not None and p.disconnected
154154
for p in self._pipes.values()):
155155
self._finished = True
156-
self._loop.call_soon(self._call_connection_lost, None)
156+
self._call(self._call_connection_lost, None)
157157

158158
def _call_connection_lost(self, exc):
159159
try:

Lib/asyncio/windows_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def finish_accept_pipe(trans, key, ov):
402402
ov.getresult()
403403
return pipe
404404

405-
# FIXME: Tulip issue 196: why to we neeed register=False?
405+
# FIXME: Tulip issue 196: why do we need register=False?
406406
# See also the comment in the _register() method
407407
return self._register(ov, pipe, finish_accept_pipe,
408408
register=False)

Lib/asyncio/windows_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ class PipeHandle:
134134
def __init__(self, handle):
135135
self._handle = handle
136136

137+
def __repr__(self):
138+
if self._handle != -1:
139+
handle = 'handle=%r' % self._handle
140+
else:
141+
handle = 'closed'
142+
return '<%s %s>' % (self.__class__.__name__, handle)
143+
137144
@property
138145
def handle(self):
139146
return self._handle

0 commit comments

Comments
 (0)