--- Modules/_testcapimodule.c | 2 -- Modules/_threadmodule.c | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -3651,8 +3651,6 @@ temporary_c_thread(void *data) PyGILState_Release(state); PyThread_release_lock(test_c_thread->exit_event); - - PyThread_exit_thread(); } static PyObject * --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -1027,7 +1027,10 @@ t_bootstrap(void *boot_raw) nb_threads--; PyThreadState_Clear(tstate); PyThreadState_DeleteCurrent(); - PyThread_exit_thread(); + + // bpo-44434: Don't call explicitly PyThread_exit_thread(). On Linux with + // the glibc, pthread_exit() can abort the whole process if dlopen() fails + // to open the libgcc_s.so library (ex: EMFILE error). } static PyObject *