Skip to content

Commit 9eeea2e

Browse files
committed
Don't lock on the GIL-ful build.
1 parent 2fcee90 commit 9eeea2e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Include/internal/pycore_atexit.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ struct atexit_state {
5252
atexit_py_callback **callbacks;
5353
int ncallbacks;
5454
int callback_len;
55-
55+
#ifdef Py_GIL_DISABLED
5656
PyMutex lock;
57+
#endif
5758
};
5859

5960
// Export for '_interpchannels' shared extension

Modules/atexitmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,15 @@
1212
#include "pycore_interp.h" // PyInterpreterState.atexit
1313
#include "pycore_pystate.h" // _PyInterpreterState_GET
1414

15+
#ifdef Py_GIL_DISABLED
1516
/* Note: anything declared as static in this file assumes the lock is held
1617
* (except for the Python-level functions) */
1718
#define _PyAtExit_LOCK(state) PyMutex_Lock(&state->lock);
1819
#define _PyAtExit_UNLOCK(state) PyMutex_Unlock(&state->lock);
20+
#else
21+
#define _PyAtExit_LOCK(state)
22+
#define _PyAtExit_UNLOCK(state)
23+
#endif
1924

2025
/* ===================================================================== */
2126
/* Callback machinery. */

0 commit comments

Comments
 (0)