bpo-33608: Factor out a private, per-interpreter _Py_AddPendingCall(). by ericsnowcurrently · Pull Request #13714 · python/cpython (original) (raw)
This is effectively an un-revert of #11617 and #12024 (reverted in #12159). Portions of those were merged in other PRs (with lower risk) and this represents the remainder. Note that I found 3 different bugs in the original PRs and have fixed them here.
I also tried again (with some tweaks) in #12360, which I ended up reverting in #12806. For this attempt I am dropping the code that calls any remaining pending calls during runtime finalization. We'll see if the FreeBSD buildbot still hates me. :)