Skip to content

Commit 602764f

Browse files
committed
drop GIL while waiting for all threads to join
1 parent 1f01f42 commit 602764f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

source/common.c

+5
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,14 @@ PyObject *aws_py_thread_join_all_managed(PyObject *self, PyObject *args) {
4747
}
4848
aws_thread_set_managed_join_timeout_ns(timeout_ns);
4949

50+
/* clang-format off */
51+
Py_BEGIN_ALLOW_THREADS
52+
/* Drop GIL to allow other threads callback into python to finish joining. */
5053
if (aws_thread_join_all_managed()) {
5154
Py_RETURN_FALSE;
5255
}
56+
Py_END_ALLOW_THREADS
57+
/* clang-format on */
5358

5459
Py_RETURN_TRUE;
5560
}

test/test_s3.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -666,9 +666,10 @@ def before_fork(self):
666666
CRT_S3_CLIENT = None
667667
gc.collect()
668668
self.assertTrue(shutdown_event.wait(self.timeout))
669-
join_all_native_threads(timeout_sec=0.1)
669+
self.assertTrue(join_all_native_threads(timeout_sec=0.1))
670670
except Exception as e:
671671
print(f"before_fork error: {e}")
672+
# fail hard
672673
exit(-1)
673674

674675
@unittest.skipIf(sys.platform.startswith('win') or sys.platform == 'darwin',

0 commit comments

Comments
 (0)