◐ Shell
clean mode source ↗

[WIP] bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). by ericsnowcurrently · Pull Request #9334 · python/cpython

This is part of the work to improve isolation between subinterpreters. We need a way for one interpreter to ask another interpreter to do small low-level tasks, like safely decref an object owned by the other interpreter. The existing Py_AddPendingCall() (part of the public C-API) is specific to the main interpreter, so we factor out a private per-interpreter _Py_AddPendingCall(). This involves moving the global "pending calls" state to PyInterpreterState.

As part of this change, we start tracking if each interpreter is "active" or finalizing. "Active" means that the interpreter is currently running the eval loop. We also start tracking the per-interpreter "active" thread ID rather than the global "main" thread ID.

https://bugs.python.org/issue33608