Skip to content

Commit 54dc3b5

Browse files
Wait for all the threads to finalize.
1 parent ad9bbce commit 54dc3b5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Modules/_threadmodule.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ module_threads_reinit(struct module_threads *threads)
8282
static void
8383
module_threads_fini(struct module_threads *threads)
8484
{
85+
// Wait for all the threads to finalize.
86+
PyThread_acquire_lock(threads->mutex, WAIT_LOCK);
87+
while (threads->head != NULL) {
88+
PyThread_release_lock(threads->mutex);
89+
// XXX Sleep?
90+
PyThread_acquire_lock(threads->mutex, WAIT_LOCK);
91+
}
92+
PyThread_release_lock(threads->mutex);
93+
8594
PyThread_free_lock(threads->mutex);
8695
}
8796

0 commit comments

Comments
 (0)