|
102 | 102 | else:
|
103 | 103 | if _can_fork_exec:
|
104 | 104 | from _posixsubprocess import fork_exec as _fork_exec
|
| 105 | + # used in methods that are called by __del__ |
| 106 | + _waitpid = os.waitpid |
| 107 | + _waitstatus_to_exitcode = os.waitstatus_to_exitcode |
| 108 | + _WIFSTOPPED = os.WIFSTOPPED |
| 109 | + _WSTOPSIG = os.WSTOPSIG |
| 110 | + _WNOHANG = os.WNOHANG |
105 | 111 | else:
|
106 | 112 | _fork_exec = None
|
| 113 | + _waitpid = None |
| 114 | + _waitstatus_to_exitcode = None |
| 115 | + _WIFSTOPPED = None |
| 116 | + _WSTOPSIG = None |
| 117 | + _WNOHANG = None |
107 | 118 | import select
|
108 | 119 | import selectors
|
109 | 120 |
|
@@ -1890,19 +1901,19 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
|
1890 | 1901 |
|
1891 | 1902 |
|
1892 | 1903 | def _handle_exitstatus(self, sts,
|
1893 |
| - waitstatus_to_exitcode=os.waitstatus_to_exitcode, |
1894 |
| - _WIFSTOPPED=os.WIFSTOPPED, |
1895 |
| - _WSTOPSIG=os.WSTOPSIG): |
| 1904 | + _waitstatus_to_exitcode=_waitstatus_to_exitcode, |
| 1905 | + _WIFSTOPPED=_WIFSTOPPED, |
| 1906 | + _WSTOPSIG=_WSTOPSIG): |
1896 | 1907 | """All callers to this function MUST hold self._waitpid_lock."""
|
1897 | 1908 | # This method is called (indirectly) by __del__, so it cannot
|
1898 | 1909 | # refer to anything outside of its local scope.
|
1899 | 1910 | if _WIFSTOPPED(sts):
|
1900 | 1911 | self.returncode = -_WSTOPSIG(sts)
|
1901 | 1912 | else:
|
1902 |
| - self.returncode = waitstatus_to_exitcode(sts) |
| 1913 | + self.returncode = _waitstatus_to_exitcode(sts) |
1903 | 1914 |
|
1904 |
| - def _internal_poll(self, _deadstate=None, _waitpid=os.waitpid, |
1905 |
| - _WNOHANG=os.WNOHANG, _ECHILD=errno.ECHILD): |
| 1915 | + def _internal_poll(self, _deadstate=None, _waitpid=_waitpid, |
| 1916 | + _WNOHANG=_WNOHANG, _ECHILD=errno.ECHILD): |
1906 | 1917 | """Check if child process has terminated. Returns returncode
|
1907 | 1918 | attribute.
|
1908 | 1919 |
|
|
0 commit comments