Python 3.14+concurrent.interpretersexception
concurrent.interpreters.NotShareableError
exceptions
The object cannot be sent to another interpreter (Python 3.14+); a subclass of TypeError.
Syntax
raise concurrent.interpreters.NotShareableError
The trap is the inheritance: it is a TypeError subclass, so a broad except TypeError around your data passing will swallow it silently and send you hunting for a bug in the arguments. The shareable set is narrow — simple immutable values pass, lists, dicts and your own classes do not — so check is_shareable() up front, or hand the data over serialized, e.g. as a JSON string.
Examples
from concurrent import interpreters # Python 3.14+
print(issubclass(interpreters.NotShareableError, TypeError)) # → True
print(interpreters.is_shareable(42)) # → True
print(interpreters.is_shareable([1, 2, 3])) # → False
interp = interpreters.create()
try:
interp.prepare_main(data=object()) # object() не переносится между интерпретаторами
except interpreters.NotShareableError as e:
print(type(e).__name__) # → NotShareableError
interp.prepare_main(n=42) # число — переносится
interp.close()
See also
Open in the full glossarydocs.python.orgReport an inaccuracy