diff options
author | mpage <mpage@meta.com> | 2024-07-19 17:22:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-19 17:22:02 (GMT) |
commit | e059aa6b01030310125477c3ed1da0491020fe10 (patch) | |
tree | c62b22c966cfa6cdd0d53779d3e9ad965713bf2e /Include | |
parent | 2009e25e26040dca32696e70f91f13665350e7fd (diff) | |
download | cpython-e059aa6b01030310125477c3ed1da0491020fe10.zip cpython-e059aa6b01030310125477c3ed1da0491020fe10.tar.gz cpython-e059aa6b01030310125477c3ed1da0491020fe10.tar.bz2 |
gh-120973: Fix thread-safety issues with `threading.local` (#121655)
This is a small refactoring to the current design that allows us to
avoid manually iterating over threads.
This should also fix gh-118490.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/cpython/pystate.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h index bb2af78..f005729 100644 --- a/Include/cpython/pystate.h +++ b/Include/cpython/pystate.h @@ -192,6 +192,14 @@ struct _ts { PyObject *previous_executor; uint64_t dict_global_version; + + /* Used to store/retrieve `threading.local` keys/values for this thread */ + PyObject *threading_local_key; + + /* Used by `threading.local`s to be remove keys/values for dying threads. + The PyThreadObject must hold the only reference to this value. + */ + PyObject *threading_local_sentinel; }; #ifdef Py_DEBUG |