@@ -214,14 +214,22 @@ def _process_exited(self, returncode):
214
214
# asyncio uses a child watcher: copy the status into the Popen
215
215
# object. On Python 3.6, it is required to avoid a ResourceWarning.
216
216
self ._proc .returncode = returncode
217
- self ._call (self ._protocol .process_exited )
218
- self ._try_finish ()
219
217
220
- # wake up futures waiting for wait()
221
- for waiter in self ._exit_waiters :
222
- if not waiter .cancelled ():
223
- waiter .set_result (returncode )
224
- self ._exit_waiters = None
218
+ def __process_exited ():
219
+ self ._protocol .process_exited ()
220
+ # Since process exited, clear all pipes
221
+ for proto in self ._pipes .values ():
222
+ if proto is None :
223
+ continue
224
+ proto .pipe .close ()
225
+ # Call _wait waiters
226
+ for waiter in self ._exit_waiters :
227
+ if not waiter .cancelled ():
228
+ waiter .set_result (self ._returncode )
229
+ self ._exit_waiters = None
230
+
231
+ self ._call (__process_exited )
232
+ self ._try_finish ()
225
233
226
234
async def _wait (self ):
227
235
"""Wait until the process exit and return the process return code.
@@ -252,6 +260,7 @@ def _call_connection_lost(self, exc):
252
260
self ._protocol = None
253
261
254
262
263
+
255
264
class WriteSubprocessPipeProto (protocols .BaseProtocol ):
256
265
257
266
def __init__ (self , proc , fd ):
0 commit comments