mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
[3.11] GH-100892: Fix race in clearing threading.local
(GH-100922). (#100937)
(cherry picked from commit 762745a124
)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
This commit is contained in:
parent
1b2459dc64
commit
e707671684
4 changed files with 73 additions and 19 deletions
|
@ -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
|
||||
|
||||
|
@ -197,6 +198,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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue