New submission from Xuan Hu <huxuan8218...@gmail.com>:
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 ---------- components: Library (Lib) messages: 357568 nosy: Xuan Hu priority: normal severity: normal status: open title: Subprocess failed to kill child process after timeout when using with statement type: behavior versions: Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38930> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com