()
| 227 | |
| 228 | |
| 229 | def _check_tracing_other_threads(): |
| 230 | import pydevd_tracing |
| 231 | import time |
| 232 | from tests_python.debugger_unittest import wait_for_condition |
| 233 | import _thread |
| 234 | |
| 235 | # This method is called in a subprocess, so, make sure we exit properly even if we somehow |
| 236 | # deadlock somewhere else. |
| 237 | def dump_threads_and_kill_on_timeout(): |
| 238 | time.sleep(10) |
| 239 | from _pydevd_bundle import pydevd_utils |
| 240 | |
| 241 | pydevd_utils.dump_threads() |
| 242 | time.sleep(1) |
| 243 | import os |
| 244 | |
| 245 | os._exit(77) |
| 246 | |
| 247 | _thread.start_new_thread(dump_threads_and_kill_on_timeout, ()) |
| 248 | |
| 249 | def method(): |
| 250 | while True: |
| 251 | trace_func = sys.gettrace() |
| 252 | if trace_func: |
| 253 | threading.current_thread().trace_func = trace_func |
| 254 | break |
| 255 | time.sleep(0.01) |
| 256 | |
| 257 | def dummy_thread_method(): |
| 258 | threads.append(threading.current_thread()) |
| 259 | method() |
| 260 | |
| 261 | threads = [] |
| 262 | threads.append(threading.Thread(target=method)) |
| 263 | threads[-1].daemon = True |
| 264 | threads[-1].start() |
| 265 | _thread.start_new_thread(dummy_thread_method, ()) |
| 266 | |
| 267 | wait_for_condition(lambda: len(threads) == 2, msg=lambda: "Found threads: %s" % (threads,)) |
| 268 | |
| 269 | def tracing_func(frame, event, args): |
| 270 | return tracing_func |
| 271 | |
| 272 | assert pydevd_tracing.set_trace_to_threads(tracing_func) == 0 |
| 273 | |
| 274 | def check_threads_tracing_func(): |
| 275 | for t in threads: |
| 276 | if getattr(t, "trace_func", None) != tracing_func: |
| 277 | return False |
| 278 | return True |
| 279 | |
| 280 | wait_for_condition(check_threads_tracing_func) |
| 281 | |
| 282 | assert tracing_func == sys.gettrace() |
| 283 | |
| 284 | |
| 285 | def _build_launch_env(): |
nothing calls this directly
no test coverage detected