Skip to content

Commit da9b606

Browse files
committed
Use PyEvent instead of _PySemaphore
1 parent 453a468 commit da9b606

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

Programs/_testembed.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,11 +2343,11 @@ test_get_incomplete_frame(void)
23432343
}
23442344

23452345
static void
2346-
do_gilstate_ensure(void *semaphore_ptr)
2346+
do_gilstate_ensure(void *event_ptr)
23472347
{
2348-
_PySemaphore *semaphore = (_PySemaphore *)semaphore_ptr;
2348+
PyEvent *event = (PyEvent *)event_ptr;
23492349
// Signal to the calling thread that we've started
2350-
_PySemaphore_Wakeup(semaphore);
2350+
_PyEvent_Notify(event);
23512351
PyGILState_Ensure(); // This should hang
23522352
assert(NULL);
23532353
}
@@ -2359,15 +2359,13 @@ test_gilstate_after_finalization(void)
23592359
Py_Finalize();
23602360
PyThread_handle_t handle;
23612361
PyThread_ident_t ident;
2362-
_PySemaphore semaphore;
2363-
_PySemaphore_Init(&semaphore);
2364-
if (PyThread_start_joinable_thread(&do_gilstate_ensure, &semaphore, &ident, &handle) < 0) {
2362+
PyEvent event = {};
2363+
if (PyThread_start_joinable_thread(&do_gilstate_ensure, &event, &ident, &handle) < 0) {
23652364
return -1;
23662365
}
2367-
_PySemaphore_Wait(&semaphore, /*timeout_ns=*/-1, /*detach=*/0);
2366+
PyEvent_Wait(&event);
23682367
// We're now pretty confident that the thread went for
23692368
// PyGILState_Ensure(), but that means it got hung.
2370-
_PySemaphore_Destroy(&semaphore);
23712369
return PyThread_detach_thread(handle);
23722370
}
23732371

0 commit comments

Comments
 (0)