Commit f0af9df Fabien Coelho
committed
1 parent c5063d8 commit f0af9df Copy full SHA for f0af9df
File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -656,4 +656,24 @@ def banged(s: str, n: int) -> str:
656
656
assert banged ("a" , 3 ) == "aaa!" # hit
657
657
assert cache .hits () == 0.5
658
658
659
+ # reset stats
660
+ cache .reset ()
661
+
662
+ import threading
663
+ NTHREADS = 4
664
+ barrier = threading .barrier (NTHREADS , timeout = 2 )
665
+
666
+ def run ():
667
+ barrier .wait ()
668
+ for s in ("a" , "b" , "c" ):
669
+ for n in range (3 ):
670
+ assert banged (s , n ) == s * n + "!"
671
+ barrier .wait ()
672
+
673
+ threads = [ threading .Thread (target = run , name = f"thread { i } " ) for i in range (NTHREADS ) ]
674
+ map (lambda t : t .start (), threads )
675
+ map (lambda t : t .join (), threads )
676
+
677
+ assert cache .hits () == 0.25
678
+
659
679
assert not sys ._is_gil_enabled ()
You can’t perform that action at this time.
0 commit comments