File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ extern "C" {
11
11
#include "pycore_atomic.h"
12
12
#include "pythread.h"
13
13
14
+ PyAPI_FUNC (int ) _Py_MakePendingCalls (void );
15
+
14
16
struct _pending_calls {
15
17
PyThread_type_lock lock ;
16
18
/* Request for running pending calls. */
Original file line number Diff line number Diff line change @@ -459,6 +459,14 @@ make_pending_calls(void)
459
459
return res ;
460
460
}
461
461
462
+ int
463
+ _Py_MakePendingCalls (void )
464
+ {
465
+ assert (PyGILState_Check ());
466
+
467
+ return make_pending_calls ();
468
+ }
469
+
462
470
/* Py_MakePendingCalls() is a simple wrapper for the sake
463
471
of backward-compatibility. */
464
472
int
Original file line number Diff line number Diff line change @@ -1462,8 +1462,20 @@ Py_EndInterpreter(PyThreadState *tstate)
1462
1462
Py_FatalError ("Py_EndInterpreter: thread still has a frame" );
1463
1463
interp -> finalizing = 1 ;
1464
1464
1465
+ // Wrap up existing threads.
1465
1466
wait_for_thread_shutdown ();
1466
1467
1468
+ // Make any remaining pending calls.
1469
+ if (_Py_atomic_load_relaxed (& _PyRuntime .ceval .pending .calls_to_do )) {
1470
+ if (_Py_MakePendingCalls () < 0 ) {
1471
+ PyObject * exc , * val , * tb ;
1472
+ PyErr_Fetch (& exc , & val , & tb );
1473
+ PyErr_BadInternalCall ();
1474
+ _PyErr_ChainExceptions (exc , val , tb );
1475
+ PyErr_Print ();
1476
+ }
1477
+ }
1478
+
1467
1479
call_py_exitfuncs (interp );
1468
1480
1469
1481
if (tstate != interp -> tstate_head || tstate -> next != NULL )
You can’t perform that action at this time.
0 commit comments