MCPcopy Index your code
hub / github.com/python/cpython / _close_pipe_fds

Method _close_pipe_fds

Lib/subprocess.py:1350–1377  ·  view source on GitHub ↗
(self,
                        p2cread, p2cwrite,
                        c2pread, c2pwrite,
                        errread, errwrite)

Source from the content-addressed store, hash-verified

1348 raise # resume the KeyboardInterrupt
1349
1350 def _close_pipe_fds(self,
1351 p2cread, p2cwrite,
1352 c2pread, c2pwrite,
1353 errread, errwrite):
1354 # self._devnull is not always defined.
1355 devnull_fd = getattr(self, '_devnull', None)
1356
1357 with contextlib.ExitStack() as stack:
1358 if _mswindows:
1359 if p2cread != -1:
1360 stack.callback(p2cread.Close)
1361 if c2pwrite != -1:
1362 stack.callback(c2pwrite.Close)
1363 if errwrite != -1:
1364 stack.callback(errwrite.Close)
1365 else:
1366 if p2cread != -1 and p2cwrite != -1 and p2cread != devnull_fd:
1367 stack.callback(os.close, p2cread)
1368 if c2pwrite != -1 and c2pread != -1 and c2pwrite != devnull_fd:
1369 stack.callback(os.close, c2pwrite)
1370 if errwrite != -1 and errread != -1 and errwrite != devnull_fd:
1371 stack.callback(os.close, errwrite)
1372
1373 if devnull_fd is not None:
1374 stack.callback(os.close, devnull_fd)
1375
1376 # Prevent a double close of these handles/fds from __init__ on error.
1377 self._closed_child_pipe_fds = True
1378
1379 @contextlib.contextmanager
1380 def _on_error_fd_closer(self):

Callers 2

_execute_childMethod · 0.95
_posix_spawnMethod · 0.95

Calls 1

callbackMethod · 0.45

Tested by

no test coverage detected