(self)
| 1102 | self.kwargs = kwargs |
| 1103 | |
| 1104 | def __call__(self): |
| 1105 | # We monkey-patch the thread creation so that this function is called in the new thread. At this point |
| 1106 | # we notify of its creation and start tracing it. |
| 1107 | py_db = get_global_debugger() |
| 1108 | |
| 1109 | thread_id = None |
| 1110 | if py_db is not None: |
| 1111 | # Note: if this is a thread from threading.py, we're too early in the boostrap process (because we mocked |
| 1112 | # the start_new_thread internal machinery and thread._bootstrap has not finished), so, the code below needs |
| 1113 | # to make sure that we use the current thread bound to the original function and not use |
| 1114 | # threading.current_thread() unless we're sure it's a dummy thread. |
| 1115 | t = getattr(self.original_func, "__self__", getattr(self.original_func, "im_self", None)) |
| 1116 | if not isinstance(t, threading.Thread): |
| 1117 | # This is not a threading.Thread but a Dummy thread (so, get it as a dummy thread using |
| 1118 | # currentThread). |
| 1119 | t = threading.current_thread() |
| 1120 | |
| 1121 | if not getattr(t, "is_pydev_daemon_thread", False): |
| 1122 | thread_id = get_current_thread_id(t) |
| 1123 | py_db.notify_thread_created(thread_id, t) |
| 1124 | _on_set_trace_for_new_thread(py_db) |
| 1125 | |
| 1126 | if getattr(py_db, "thread_analyser", None) is not None: |
| 1127 | try: |
| 1128 | from _pydevd_bundle.pydevd_concurrency_analyser.pydevd_concurrency_logger import log_new_thread |
| 1129 | |
| 1130 | log_new_thread(py_db, t) |
| 1131 | except: |
| 1132 | sys.stderr.write("Failed to detect new thread for visualization") |
| 1133 | try: |
| 1134 | ret = self.original_func(*self.args, **self.kwargs) |
| 1135 | finally: |
| 1136 | if thread_id is not None: |
| 1137 | if py_db is not None: |
| 1138 | # At thread shutdown we only have pydevd-related code running (which shouldn't |
| 1139 | # be tracked). |
| 1140 | py_db.disable_tracing() |
| 1141 | py_db.notify_thread_not_alive(thread_id) |
| 1142 | |
| 1143 | return ret |
| 1144 | |
| 1145 | |
| 1146 | class _NewThreadStartupWithoutTrace: |
nothing calls this directly
no test coverage detected