Commit 49c2e12 Fabien Coelho
committed
1 parent d162280 commit 49c2e12 Copy full SHA for 49c2e12
File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env python
2
2
3
+ import sys
3
4
import socket
4
5
import importlib
5
6
import cachetools as ct
@@ -628,3 +629,26 @@ def m1(i: int):
628
629
pytest .fail ("must raise an exception" )
629
630
except Exception as e :
630
631
assert "method: bad-method" in str (e )
632
+
633
+ def test_nogil ():
634
+
635
+ try :
636
+ if sys ._is_gil_enabled ():
637
+ pytest .skip ("gil is enabled" )
638
+ except AttributeError as e :
639
+ assert "_is_gil_enabled" in str (e )
640
+ pytest .skip ("nogil not supported" )
641
+
642
+ assert sys .is_gil_enabled ()
643
+
644
+ cache = ctu .StatsCache (ctu .DictCache ())
645
+
646
+ @ctu .cached (ctu .AutoPrefixedCache (cache ))
647
+ def repeat (s : str , n : int ) -> str :
648
+ return s * n
649
+
650
+ assert foo ("a" , 3 ) == "aaa" and foo ("a" , 2 ) == "aa"
651
+ assert foo ("a" , 3 ) == "aaa" and foo ("a" , 2 ) == "aa"
652
+ assert cache .hits () == 0.5
653
+
654
+ assert sys .is_gil_enabled ()
You can’t perform that action at this time.
0 commit comments