Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 99ea70c

Browse filesBrowse files
Only trigger events on thread calling start_trace
1 parent 2641c05 commit 99ea70c
Copy full SHA for 99ea70c

File tree

1 file changed

+6
-0
lines changed
Filter options

1 file changed

+6
-0
lines changed

‎Lib/bdb.py

Copy file name to clipboardExpand all lines: Lib/bdb.py
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import fnmatch
44
import sys
5+
import threading
56
import os
67
from inspect import CO_GENERATOR, CO_COROUTINE, CO_ASYNC_GENERATOR
78

@@ -36,9 +37,11 @@ def __init__(self):
3637
self._name = 'bdbtracer'
3738
self._tracefunc = None
3839
self._disable_current_event = False
40+
self._tracing_thread = None
3941

4042
def start_trace(self, tracefunc):
4143
self._tracefunc = tracefunc
44+
self._tracing_thread = threading.current_thread()
4245
curr_tool = sys.monitoring.get_tool(self._tool_id)
4346
if curr_tool is None:
4447
sys.monitoring.use_tool_id(self._tool_id, self._name)
@@ -57,6 +60,7 @@ def start_trace(self, tracefunc):
5760
sys.monitoring.set_events(self._tool_id, all_events)
5861

5962
def stop_trace(self):
63+
self._tracing_thread = None
6064
curr_tool = sys.monitoring.get_tool(self._tool_id)
6165
if curr_tool != self._name:
6266
return
@@ -78,6 +82,8 @@ def callback_wrapper(func):
7882

7983
@functools.wraps(func)
8084
def wrapper(self, *args):
85+
if self._tracing_thread != threading.current_thread():
86+
return
8187
try:
8288
frame = sys._getframe().f_back
8389
ret = func(self, frame, *args)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.