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

Method _on_error_fd_closer

Lib/subprocess.py:1380–1397  ·  view source on GitHub ↗

Helper to ensure file descriptors opened in _get_handles are closed

(self)

Source from the content-addressed store, hash-verified

1378
1379 @contextlib.contextmanager
1380 def _on_error_fd_closer(self):
1381 """Helper to ensure file descriptors opened in _get_handles are closed"""
1382 to_close = []
1383 try:
1384 yield to_close
1385 except:
1386 if hasattr(self, '_devnull'):
1387 to_close.append(self._devnull)
1388 del self._devnull
1389 for fd in to_close:
1390 try:
1391 if _mswindows and isinstance(fd, Handle):
1392 fd.Close()
1393 else:
1394 os.close(fd)
1395 except OSError:
1396 pass
1397 raise
1398
1399 if _mswindows:
1400 #

Callers 1

_get_handlesMethod · 0.95

Calls 3

CloseMethod · 0.80
appendMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected