File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import fnmatch
44import sys
5+ import threading
56import os
67import weakref
78from inspect import CO_GENERATOR , CO_COROUTINE , CO_ASYNC_GENERATOR
@@ -37,9 +38,11 @@ def __init__(self):
3738 self ._name = 'bdbtracer'
3839 self ._tracefunc = None
3940 self ._disable_current_event = False
41+ self ._tracing_thread = None
4042
4143 def start_trace (self , tracefunc ):
4244 self ._tracefunc = tracefunc
45+ self ._tracing_thread = threading .current_thread ()
4346 curr_tool = sys .monitoring .get_tool (self ._tool_id )
4447 if curr_tool is None :
4548 sys .monitoring .use_tool_id (self ._tool_id , self ._name )
@@ -58,6 +61,7 @@ def start_trace(self, tracefunc):
5861 sys .monitoring .set_events (self ._tool_id , all_events )
5962
6063 def stop_trace (self ):
64+ self ._tracing_thread = None
6165 curr_tool = sys .monitoring .get_tool (self ._tool_id )
6266 if curr_tool != self ._name :
6367 return
@@ -79,6 +83,8 @@ def callback_wrapper(func):
7983
8084 @functools .wraps (func )
8185 def wrapper (self , * args ):
86+ if self ._tracing_thread != threading .current_thread ():
87+ return
8288 try :
8389 frame = sys ._getframe ().f_back
8490 ret = func (self , frame , * args )
You can’t perform that action at this time.
0 commit comments