File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99import copy
1010import threading
1111import time
12- import types
1312import random
1413import textwrap
1514
@@ -2253,36 +2252,6 @@ def test_names(self):
22532252 self .assertEqual (obj .__name__ , name )
22542253 self .assertEqual (obj .__qualname__ , name )
22552254
2256- @threading_helper .requires_working_threading ()
2257- @unittest .skipUnless (support .Py_GIL_DISABLED , 'only used under free-threaded build' )
2258- def test_module_weakref (self ):
2259- # gh-135607: Avoid potential races on module weaklist under free-threaded build
2260- mod = types .ModuleType ("temp_mod" )
2261- common_ref = weakref .ref (mod )
2262- threads = []
2263- n_threads = 10
2264- b = threading .Barrier (n_threads )
2265-
2266- def weakref_mod_worker ():
2267- b .wait ()
2268- r = weakref .ref (mod )
2269- rr = r ()
2270- self .assertIs (rr , mod )
2271- self .assertIs (rr , common_ref ())
2272-
2273- for i in range (n_threads ):
2274- t = threading .Thread (target = weakref_mod_worker )
2275- threads .append (t )
2276- t .start ()
2277-
2278- for t in threads :
2279- t .join ()
2280-
2281- r = weakref .ref (mod )
2282- self .assertIsNotNone (r , "weak ref to a module should not be None" )
2283- self .assertIs (r (), common_ref ())
2284- del mod
2285-
22862255
22872256libreftest = """ Doctest for examples in the library reference: weakref.rst
22882257
You can’t perform that action at this time.
0 commit comments