Python 3.14+concurrent.interpretersexception
concurrent.interpreters.InterpreterNotFoundError
exceptions
The targeted interpreter no longer exists — closed or an unknown id (Python 3.14+); a subclass of InterpreterError.
Syntax
raise concurrent.interpreters.InterpreterNotFoundError
The usual cause is holding on to an Interpreter object after close(), or addressing an id that nothing owns any more; any exec() or call() through such a handle fails with this exception. Retrying is pointless — the interpreter is gone for good, so create a fresh one. If you handle it alongside other errors, put this except clause above InterpreterError, or the base class will swallow it first.
Examples
from concurrent import interpreters # Python 3.14+
print(issubclass(interpreters.InterpreterNotFoundError, interpreters.InterpreterError)) # → True
interp = interpreters.create()
interp.exec('x = 1')
interp.close()
try:
interp.exec('x = 2') # интерпретатор уже уничтожен
except interpreters.InterpreterNotFoundError as e:
print(type(e).__name__) # → InterpreterNotFoundError
try:
interpreters.Interpreter(999999) # такого id не существует
except interpreters.InterpreterNotFoundError:
print('нет такого интерпретатора') # → нет такого интерпретатора
See also
Open in the full glossarydocs.python.orgReport an inaccuracy