MCPcopy Create free account
hub / github.com/fabioz/PyDev.Debugger / _internal_set_trace

Function _internal_set_trace

pydevd_tracing.py:58–90  ·  view source on GitHub ↗
(tracing_func)

Source from the content-addressed store, hash-verified

56
57
58def _internal_set_trace(tracing_func):
59 if PYDEVD_USE_SYS_MONITORING:
60 raise RuntimeError("pydevd: Using sys.monitoring, sys.settrace should not be called.")
61 if TracingFunctionHolder._warn:
62 frame = get_frame()
63 if frame is not None and frame.f_back is not None:
64 filename = os.path.splitext(frame.f_back.f_code.co_filename.lower())[0]
65 if filename.endswith("threadpool") and "gevent" in filename:
66 if tracing_func is None:
67 pydev_log.debug("Disabled internal sys.settrace from gevent threadpool.")
68 return
69
70 elif not filename.endswith(
71 (
72 "threading",
73 "pydevd_tracing",
74 )
75 ):
76 message = (
77 "\nPYDEV DEBUGGER WARNING:"
78 + "\nsys.settrace() should not be used when the debugger is being used."
79 + "\nThis may cause the debugger to stop working correctly."
80 + "%s" % _get_stack_str(frame.f_back)
81 )
82
83 if message not in TracingFunctionHolder._warnings_shown:
84 # only warn about each message once...
85 TracingFunctionHolder._warnings_shown[message] = 1
86 sys.stderr.write("%s\n" % (message,))
87 sys.stderr.flush()
88
89 if TracingFunctionHolder._original_tracing:
90 TracingFunctionHolder._original_tracing(tracing_func)
91
92
93_last_tracing_func_thread_local = threading.local()

Callers

nothing calls this directly

Calls 4

get_frameFunction · 0.90
_get_stack_strFunction · 0.85
writeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected