New submission from Ruslan Kuprieiev <kupru...@gmail.com>:
subprocess keeps the list of active processes in its `_active` list. Whenever you try to Popen a new process, it is immediately (like right in the first line of Popen.__init__ [1]) trying to go clean up the old ones. If one of the processes in that list is gone, then ``` (_WaitForSingleObject(self._handle, 0) ``` [2] will get `OSError: [WinError 6] The handle is invalid` and will prevent you from creating any new processes with Popen after that, because the line where that handle is removes from _active list is not reached. On *nix [3] _internal_poll will actually try-except waitpid and will catch OSError without re-raising it, so if the process is gone, it will simply report it as dead and successfully remove it from _active list. It seems like we should do the same thing on Windows and if we catch `The handle is invalid` error, just report that process as dead and remove it from _active list. [1] https://github.com/python/cpython/blob/v3.8.0b1/Lib/subprocess.py#L715 [2] https://github.com/python/cpython/blob/v3.8.0b1/Lib/subprocess.py#L1310 [3] https://github.com/python/cpython/blob/v3.8.0b1/Lib/subprocess.py#L1710 ---------- components: Windows messages: 346332 nosy: Ruslan Kuprieiev, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: subprocess.Popen._cleanup() "The handle is invalid" error when some old process is gone type: crash versions: Python 3.7 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue37380> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com