gh-87135: Raise PythonFinalizationError when joining a blocked daemon thread (gh-130402)
If `Py_IsFinalizing()` is true, non-daemon threads (other than the current one) are done, and daemon threads are prevented from running, so they cannot finalize themselves and become done. Joining them (without timeout) would block forever. Raise PythonFinalizationError instead of hanging. Raise even when a timeout is given, for consistency with trying to join your own thread. See gh-123940 for a use case: calling `join()` from `__del__`. This is ill-advised, but an exception should at least make it easier to diagnose.
P
Petr Viktorin committed
4ebbfcf30e0e2d87ff6036d4d1de0f6f0ef7c46a
Parent: 995b1a7
Committed by GitHub <noreply@github.com>
on 4/28/2025, 1:48:48 PM