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

Method _stop_locked

Lib/multiprocessing/resource_tracker.py:104–137  ·  view source on GitHub ↗
(
        self,
        close=os.close,
        waitpid=os.waitpid,
        waitstatus_to_exitcode=os.waitstatus_to_exitcode,
    )

Source from the content-addressed store, hash-verified

102 self._lock.release()
103
104 def _stop_locked(
105 self,
106 close=os.close,
107 waitpid=os.waitpid,
108 waitstatus_to_exitcode=os.waitstatus_to_exitcode,
109 ):
110 # This shouldn't happen (it might when called by a finalizer)
111 # so we check for it anyway.
112 if self._lock._recursion_count() > 1:
113 raise self._reentrant_call_error()
114 if self._fd is None:
115 # not running
116 return
117 if self._pid is None:
118 return
119
120 # closing the "alive" file descriptor stops main()
121 close(self._fd)
122 self._fd = None
123
124 try:
125 _, status = waitpid(self._pid, 0)
126 except ChildProcessError:
127 self._pid = None
128 self._exitcode = None
129 return
130
131 self._pid = None
132
133 try:
134 self._exitcode = waitstatus_to_exitcode(status)
135 except ValueError:
136 # os.waitstatus_to_exitcode may raise an exception for invalid values
137 self._exitcode = None
138
139 def getfd(self):
140 self.ensure_running()

Callers 1

_stopMethod · 0.95

Calls 4

_reentrant_call_errorMethod · 0.95
waitstatus_to_exitcodeFunction · 0.85
_recursion_countMethod · 0.80
closeFunction · 0.50

Tested by

no test coverage detected