File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3488,7 +3488,24 @@ wait_for_native_shutdown(PyInterpreterState *interp)
34883488 }
34893489 PyMutex_Unlock (& finalizing -> mutex );
34903490
3491- PyEvent_Wait (& finalizing -> finished );
3491+ PyTime_t wait_ns = 1000 * 1000 ; // 1 millisecond
3492+
3493+ while (true) {
3494+ if (PyEvent_WaitTimed (& finalizing -> finished , wait_ns , 1 )) {
3495+ // Event set
3496+ break ;
3497+ }
3498+
3499+ if (PyErr_CheckSignals ()) {
3500+ // The user CTRL+C'd us, bail out without waiting for a reference
3501+ // count of zero.
3502+ //
3503+ // This will probably cause threads to crash, but maybe that's
3504+ // better than a deadlock. It might be worth intentionally
3505+ // leaking subinterpreters to prevent some crashes here.
3506+ break ;
3507+ }
3508+ }
34923509}
34933510
34943511int Py_AtExit (void (* func )(void ))
You can’t perform that action at this time.
0 commit comments