diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index 72df78f9cc..45042c0bb8 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -58,7 +58,7 @@ acquire_timed(PyThread_type_lock lock, _PyTime_t timeout) r = PyThread_acquire_lock_timed(lock, 0, 0); if (r == PY_LOCK_FAILURE && microseconds != 0) { Py_BEGIN_ALLOW_THREADS - r = PyThread_acquire_lock_timed(lock, microseconds, 1); + r = PyThread_acquire_lock_timed(lock, microseconds, 0); Py_END_ALLOW_THREADS } diff --git a/Python/thread_pthread.h b/Python/thread_pthread.h index 0de02d6364..8a572956c1 100644 --- a/Python/thread_pthread.h +++ b/Python/thread_pthread.h @@ -351,6 +351,15 @@ PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds, } if (microseconds > 0) { + PyGILState_STATE gil_state = PyGILState_Ensure(); + int call_res = Py_MakePendingCalls(); + PyGILState_Release(gil_state); + + if (call_res < 0) { + success = PY_LOCK_FAILURE; + goto exit; + } + /* wait interrupted by a signal (EINTR): recompute the timeout */ _PyTime_t dt = deadline - _PyTime_GetMonotonicClock(); if (dt < 0) {