File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import fnmatch
4
4
import sys
5
+ import threading
5
6
import os
6
7
import weakref
7
8
from inspect import CO_GENERATOR , CO_COROUTINE , CO_ASYNC_GENERATOR
@@ -37,9 +38,11 @@ def __init__(self):
37
38
self ._name = 'bdbtracer'
38
39
self ._tracefunc = None
39
40
self ._disable_current_event = False
41
+ self ._tracing_thread = None
40
42
41
43
def start_trace (self , tracefunc ):
42
44
self ._tracefunc = tracefunc
45
+ self ._tracing_thread = threading .current_thread ()
43
46
curr_tool = sys .monitoring .get_tool (self ._tool_id )
44
47
if curr_tool is None :
45
48
sys .monitoring .use_tool_id (self ._tool_id , self ._name )
@@ -58,6 +61,7 @@ def start_trace(self, tracefunc):
58
61
sys .monitoring .set_events (self ._tool_id , all_events )
59
62
60
63
def stop_trace (self ):
64
+ self ._tracing_thread = None
61
65
curr_tool = sys .monitoring .get_tool (self ._tool_id )
62
66
if curr_tool != self ._name :
63
67
return
@@ -79,6 +83,8 @@ def callback_wrapper(func):
79
83
80
84
@functools .wraps (func )
81
85
def wrapper (self , * args ):
86
+ if self ._tracing_thread != threading .current_thread ():
87
+ return
82
88
try :
83
89
frame = sys ._getframe ().f_back
84
90
ret = func (self , frame , * args )
You can’t perform that action at this time.
0 commit comments