File tree 2 files changed +5
-7
lines changed
2 files changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ def init_execution_context():
34
34
# we should assume it's use as this will be the most "green-thread safe"
35
35
if threading_local_monkey_patched ():
36
36
from elasticapm .context .threadlocal import execution_context
37
+
37
38
return execution_context
38
39
39
40
try :
@@ -51,15 +52,15 @@ def threading_local_monkey_patched():
51
52
except ImportError :
52
53
pass
53
54
else :
54
- if is_object_patched (' _threading' , ' local' ):
55
+ if is_object_patched (" _threading" , " local" ):
55
56
return True
56
57
57
58
try :
58
59
from eventlet .patcher import is_monkey_patched
59
60
except ImportError :
60
61
pass
61
62
else :
62
- if is_monkey_patched (' thread' ):
63
+ if is_monkey_patched (" thread" ):
63
64
return True
64
65
65
66
return False
Original file line number Diff line number Diff line change @@ -9,18 +9,15 @@ def test_execution_context_backing():
9
9
10
10
if sys .version_info [0 ] == 3 and sys .version_info [1 ] >= 7 :
11
11
from elasticapm .context .contextvars import ContextVarsContext
12
+
12
13
assert isinstance (execution_context , ContextVarsContext )
13
14
else :
14
15
assert isinstance (execution_context , ThreadLocalContext )
15
16
16
17
17
18
def test_execution_context_monkeypatched (monkeypatch ):
18
19
with monkeypatch .context () as m :
19
- m .setattr (
20
- elasticapm .context ,
21
- 'threading_local_monkey_patched' ,
22
- lambda : True
23
- )
20
+ m .setattr (elasticapm .context , "threading_local_monkey_patched" , lambda : True )
24
21
execution_context = elasticapm .context .init_execution_context ()
25
22
26
23
# Should always use ThreadLocalContext when thread local is monkey patched
You can’t perform that action at this time.
0 commit comments