[issue40550] Popen.terminate fails with ProcessLookupError under certain conditions

Filipe Laíns report at bugs.python.org
Thu May 7 19:35:40 EDT 2020


Filipe Laíns <filipe.lains at gmail.com> added the comment:

This is the backtrace I get:

Traceback (most recent call last):
  File "/home/anubis/test/multiprocessing-error.py", line 16, in <module>
    proc.terminate()
  File "/home/anubis/git/cpython/Lib/subprocess.py", line 2069, in terminate
    self.send_signal(signal.SIGTERM)
  File "/home/anubis/git/cpython/Lib/subprocess.py", line 2064, in send_signal
    os.kill(self.pid, sig)
ProcessLookupError: [Errno 3] No such process

Is yours the same? This is expected, the process exited before proc.terminate().

You should wrap proc.terminate() in a try..except block:

try:
    proc.terminate()
except ProcessLookupError:
    pass

I am not sure we want to suppress this.

----------
nosy: +FFY00

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40550>
_______________________________________


More information about the Python-bugs-list mailing list