Python Glossary Русский

Python 3.3+Exceptionsexception

ProcessLookupError

built-in exceptions

The given process does not exist (a subclass of OSError).

Syntax

raise ProcessLookupError

Maps to the POSIX ESRCH error and comes out of os.kill or os.killpg when no process with that pid exists any more — usually because it exited between your check and your signal. Because of that race, the right pattern is to send the signal and catch ProcessLookupError rather than to test "is it alive?" first. Keep pid reuse in mind too: no error does not prove you hit the process you meant. (os.waitpid on a foreign or already reaped pid raises something else — ChildProcessError.)

Examples

try:
    raise ProcessLookupError
except ProcessLookupError as e:
    print(type(e).__name__)   # → ProcessLookupError

See also

Open in the full glossarydocs.python.orgReport an inaccuracy