diff options
author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2023-01-11 15:32:02 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-11 15:32:02 (GMT) |
commit | a3b65770a0c048c3feaf9c289deba9a8f0e34f72 (patch) | |
tree | 99514d1dacc93786ccd1baf8827eab155c79d1a8 /Lib/test | |
parent | 5aa8b9e70c44862cf3f600bdc329a20790b67056 (diff) | |
download | cpython-a3b65770a0c048c3feaf9c289deba9a8f0e34f72.zip cpython-a3b65770a0c048c3feaf9c289deba9a8f0e34f72.tar.gz cpython-a3b65770a0c048c3feaf9c289deba9a8f0e34f72.tar.bz2 |
[3.10] GH-100892: Fix race in clearing `threading.local` (GH-100922). (#100938)
(cherry picked from commit 762745a124cbc297cf2fe6f3ec9ca1840bb2e873)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_threading_local.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_threading_local.py b/Lib/test/test_threading_local.py index 13facb5..f1ef30e 100644 --- a/Lib/test/test_threading_local.py +++ b/Lib/test/test_threading_local.py @@ -3,6 +3,7 @@ import unittest from doctest import DocTestSuite from test import support from test.support import threading_helper +from test.support.import_helper import import_module import weakref import gc @@ -194,6 +195,18 @@ class BaseLocalTest: self.assertIsNone(wr()) + def test_threading_local_clear_race(self): + # See https://github.com/python/cpython/issues/100892 + + _testcapi = import_module('_testcapi') + _testcapi.call_in_temporary_c_thread(lambda: None, False) + + for _ in range(1000): + _ = threading.local() + + _testcapi.join_temporary_c_thread() + + class ThreadLocalTest(unittest.TestCase, BaseLocalTest): _local = _thread._local |