def attachThread(self, target=None, args=None, kwargs=None, mainThread=0): """ Public method to setup a thread for DebugClient to debug. If mainThread is non-zero, then we are attaching to the already started mainthread of the app and the rest of the args are ignored. @param target the start function of the target thread (i.e. the user code) @param args arguments to pass to target @param kwargs keyword arguments to pass to target @param mainThread non-zero, if we are attaching to the already started mainthread of the app @return The identifier of the created thread """ try: self.lockClient() newThread = DebugThread(self, target, args, kwargs, mainThread) ident = -1 if mainThread: ident = thread.get_ident() self.mainThread = newThread if self.debugging: sys.setprofile(newThread.profile) else: ident = _original_start_thread(newThread.bootstrap, ()) if self.mainThread is not None: self.tracePython = self.mainThread.tracePython newThread.set_ident(ident) self.threads[newThread.get_ident()] = newThread finally: self.unlockClient() return ident
def attachThread(self, target=None, args=None, kwargs=None, mainThread=False): """ Public method to setup a thread for DebugClient to debug. If mainThread is non-zero, then we are attaching to the already started mainthread of the app and the rest of the args are ignored. @param target the start function of the target thread (i.e. the user code) @param args arguments to pass to target @param kwargs keyword arguments to pass to target @param mainThread True, if we are attaching to the already started mainthread of the app @return identifier of the created thread """ try: self.lockClient() newThread = DebugThread(self, target, args, kwargs, mainThread) ident = -1 if mainThread: ident = _thread.get_ident() self.mainThread = newThread if self.debugging: sys.setprofile(newThread.profile) else: ident = _original_start_thread(newThread.bootstrap, ()) newThread.set_ident(ident) self.threads[newThread.get_ident()] = newThread finally: self.unlockClient() return ident