Commit 6616c8e8 authored by Matthieu Martin's avatar Matthieu Martin Committed by Facebook Github Bot

Fix possible deadlock in GILAwareManualExecutor

Summary:
See code comment

(Note: this ignores all push blocking failures!)

Reviewed By: andriigrynenko

Differential Revision: D8130722

fbshipit-source-id: c2a3e4b0de1fe7d07e28c4a7558e4367a1591ac1
parent 72cb9df4
......@@ -40,6 +40,9 @@ void GILAwareManualExecutor::waitBeforeDrive() {
// Release GIL before waiting on lock
auto* pyThreadState = PyEval_SaveThread();
SCOPE_EXIT {
// Release lock before re-acquiring GIL,
// to avoid deadlock if another GIL-owning thread is calling add
lock.unlock();
PyEval_RestoreThread(pyThreadState);
};
cv_.wait(lock, [&] { return !funcs_.empty(); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment