This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Subprocess failed to kill child process after timeout when using with statement
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Xuan Hu
Priority: normal Keywords:

Created on 2019-11-27 12:43 by Xuan Hu, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg357568 - (view) Author: Xuan Hu (Xuan Hu) Date: 2019-11-27 12:43
The original issue is that the `timeout` in `subprocess.run()` does not work properly, so I try to use `subprocess.Popen()` instead. There are two references I found, [1] is the implementation of `subprocess.run()` and [2] is the example for `Popen.communicate()`. Surprisingly, [2] works for me, and seems the `with` statement is the cause of the issue.

I created a snippet [3] to reproduce the bug, note that `ffmpeg` is needed to run the script. Ideally, all the time should be less than 0.1 or just a little bit greater than 0.1, but when using the `with` statement, the result would be much larger than that.

[1] https://github.com/python/cpython/blob/0f9c9d53283420a570850aa92869d032b40d4fba/Lib/subprocess.py#L489
[2] https://docs.python.org/3/library/subprocess.html#subprocess.Popen.communicate
[3] https://gist.github.com/huxuan/d58a5899be9b42e0936c71dd7884442a
msg357592 - (view) Author: Xuan Hu (Xuan Hu) Date: 2019-11-28 04:46
Seems it is a false negative report. Close it temporarily.
History
Date User Action Args
2022-04-11 14:59:23adminsetgithub: 83111
2019-11-28 04:46:35Xuan Husetstatus: open -> closed

messages: + msg357592
stage: resolved
2019-11-27 12:43:21Xuan Hucreate