Enables tracing. If in regular mode (tracing), will set the tracing function to the tracing function for this thread -- by default it's `PyDB.trace_dispatch`, but after `PyDB.enable_tracing` is called with a `thread_trace_func`, the given function will be th
(self, thread_trace_func=None, apply_to_all_threads=False)
| 1123 | return thread_trace_func |
| 1124 | |
| 1125 | def enable_tracing(self, thread_trace_func=None, apply_to_all_threads=False): |
| 1126 | """ |
| 1127 | Enables tracing. |
| 1128 | |
| 1129 | If in regular mode (tracing), will set the tracing function to the tracing |
| 1130 | function for this thread -- by default it's `PyDB.trace_dispatch`, but after |
| 1131 | `PyDB.enable_tracing` is called with a `thread_trace_func`, the given function will |
| 1132 | be the default for the given thread. |
| 1133 | |
| 1134 | :param bool apply_to_all_threads: |
| 1135 | If True we'll set the tracing function in all threads, not only in the current thread. |
| 1136 | If False only the tracing for the current function should be changed. |
| 1137 | In general apply_to_all_threads should only be true if this is the first time |
| 1138 | this function is called on a multi-threaded program (either programmatically or attach |
| 1139 | to pid). |
| 1140 | """ |
| 1141 | if PYDEVD_USE_SYS_MONITORING: |
| 1142 | pydevd_sys_monitoring.start_monitoring(all_threads=apply_to_all_threads) |
| 1143 | return |
| 1144 | |
| 1145 | if pydevd_gevent_integration is not None: |
| 1146 | pydevd_gevent_integration.enable_gevent_integration() |
| 1147 | |
| 1148 | if self.frame_eval_func is not None: |
| 1149 | self.frame_eval_func() |
| 1150 | pydevd_tracing.SetTrace(self.dummy_trace_dispatch) |
| 1151 | |
| 1152 | if IS_CPYTHON and apply_to_all_threads: |
| 1153 | pydevd_tracing.set_trace_to_threads(self.dummy_trace_dispatch) |
| 1154 | return |
| 1155 | |
| 1156 | if apply_to_all_threads: |
| 1157 | # If applying to all threads, don't use the local thread trace function. |
| 1158 | assert thread_trace_func is not None |
| 1159 | else: |
| 1160 | if thread_trace_func is None: |
| 1161 | thread_trace_func = self.get_thread_local_trace_func() |
| 1162 | else: |
| 1163 | self._local_thread_trace_func.thread_trace_func = thread_trace_func |
| 1164 | |
| 1165 | pydevd_tracing.SetTrace(thread_trace_func) |
| 1166 | if IS_CPYTHON and apply_to_all_threads: |
| 1167 | pydevd_tracing.set_trace_to_threads(thread_trace_func) |
| 1168 | |
| 1169 | def disable_tracing(self): |
| 1170 | if PYDEVD_USE_SYS_MONITORING: |
no test coverage detected