(tracing_func)
| 94 | |
| 95 | |
| 96 | def SetTrace(tracing_func): |
| 97 | if PYDEVD_USE_SYS_MONITORING: |
| 98 | raise RuntimeError("SetTrace should not be used when using sys.monitoring.") |
| 99 | _last_tracing_func_thread_local.tracing_func = tracing_func |
| 100 | |
| 101 | if tracing_func is not None: |
| 102 | if set_trace_to_threads(tracing_func, thread_idents=[thread.get_ident()], create_dummy_thread=False) == 0: |
| 103 | # If we can use our own tracer instead of the one from sys.settrace, do it (the reason |
| 104 | # is that this is faster than the Python version because we don't call |
| 105 | # PyFrame_FastToLocalsWithError and PyFrame_LocalsToFast at each event! |
| 106 | # (the difference can be huge when checking line events on frames as the |
| 107 | # time increases based on the number of local variables in the scope) |
| 108 | # See: InternalCallTrampoline (on the C side) for details. |
| 109 | return |
| 110 | |
| 111 | # If it didn't work (or if it was None), use the Python version. |
| 112 | set_trace = TracingFunctionHolder._original_tracing or sys.settrace |
| 113 | set_trace(tracing_func) |
| 114 | |
| 115 | |
| 116 | def reapply_settrace(): |
no test coverage detected