mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
GH-100892: Fix race in clearing threading.local
(#100922)
This commit is contained in:
parent
847d7708ba
commit
762745a124
4 changed files with 70 additions and 15 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
|
||||
|
||||
# Modules under test
|
||||
|
@ -196,6 +197,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