[issue37380] subprocess.Popen._cleanup() "The handle is invalid" error when some old process is gone

2019-06-29 Thread Ruslan Kuprieiev


Ruslan Kuprieiev  added the comment:

The `_active` code is pretty old and has not changed since 2.7, so it makes 
sense to backport it for now(also, should be very trivial to do that). To me, 
it doesn't seem dangerous to backport that, but I would love to hear what Eryk 
and others think :)

--

___
Python tracker 
<https://bugs.python.org/issue37380>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37380] subprocess.Popen._cleanup() "The handle is invalid" error when some old process is gone

2019-06-24 Thread Ruslan Kuprieiev


Ruslan Kuprieiev  added the comment:

Thanks for pointing that out! I've submitted a tiny patch to skip 
``_collect()`` and ``__del__``. Please find it in the Github PR attached. 
Looking forward to your feedback!

--

___
Python tracker 
<https://bugs.python.org/issue37380>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37380] subprocess.Popen._cleanup() "The handle is invalid" error when some old process is gone

2019-06-24 Thread Ruslan Kuprieiev


Change by Ruslan Kuprieiev :


--
pull_requests: +14176
pull_request: https://github.com/python/cpython/pull/14360

___
Python tracker 
<https://bugs.python.org/issue37380>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37380] subprocess.Popen._cleanup() "The handle is invalid" error when some old process is gone

2019-06-23 Thread Ruslan Kuprieiev


Ruslan Kuprieiev  added the comment:

Hi Eryk!

Thanks for a swift reply! So the current plan for fixing it is:

1) disable _cleanup, _active, and remove _internal_poll() for windows
2) ignore EBADF(OSError: [WinError 6] The handle is invalid) in terminate() and 
probably some other methods

Please let me know if I'm missing something. Also, is anyone working on this, 
or should I prepare a PR?

Thanks,
Ruslan

--

___
Python tracker 
<https://bugs.python.org/issue37380>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue37380] subprocess.Popen._cleanup() "The handle is invalid" error when some old process is gone

2019-06-23 Thread Ruslan Kuprieiev


New submission from Ruslan Kuprieiev :

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 
<https://bugs.python.org/issue37380>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com