aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/crossinterp.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/crossinterp.c')
-rw-r--r--Python/crossinterp.c29
1 files changed, 5 insertions, 24 deletions
diff --git a/Python/crossinterp.c b/Python/crossinterp.c
index 21b96ef05ed..f74fee38648 100644
--- a/Python/crossinterp.c
+++ b/Python/crossinterp.c
@@ -456,16 +456,17 @@ _xidregistry_clear(struct _xidregistry *xidregistry)
static void
_xidregistry_lock(struct _xidregistry *registry)
{
- if (registry->mutex != NULL) {
- PyThread_acquire_lock(registry->mutex, WAIT_LOCK);
+ if (registry->global) {
+ PyMutex_Lock(&registry->mutex);
}
+ // else: Within an interpreter we rely on the GIL instead of a separate lock.
}
static void
_xidregistry_unlock(struct _xidregistry *registry)
{
- if (registry->mutex != NULL) {
- PyThread_release_lock(registry->mutex);
+ if (registry->global) {
+ PyMutex_Unlock(&registry->mutex);
}
}
@@ -874,19 +875,10 @@ _xidregistry_init(struct _xidregistry *registry)
registry->initialized = 1;
if (registry->global) {
- // We manage the mutex lifecycle in pystate.c.
- assert(registry->mutex != NULL);
-
// Registering the builtins is cheap so we don't bother doing it lazily.
assert(registry->head == NULL);
_register_builtins_for_crossinterpreter_data(registry);
}
- else {
- // Within an interpreter we rely on the GIL instead of a separate lock.
- assert(registry->mutex == NULL);
-
- // There's nothing else to initialize.
- }
}
static void
@@ -898,17 +890,6 @@ _xidregistry_fini(struct _xidregistry *registry)
registry->initialized = 0;
_xidregistry_clear(registry);
-
- if (registry->global) {
- // We manage the mutex lifecycle in pystate.c.
- assert(registry->mutex != NULL);
- }
- else {
- // There's nothing else to finalize.
-
- // Within an interpreter we rely on the GIL instead of a separate lock.
- assert(registry->mutex == NULL);
- }
}