DebugClients/Python2/DebugClientThreads.py

changeset 5161
f7b6ded9cc37
parent 5133
b7fe69c6cb1c
equal deleted inserted replaced
5160:d8908660fc65 5161:f7b6ded9cc37
72 self.mainThread = None 72 self.mainThread = None
73 self.mainFrame = None 73 self.mainFrame = None
74 74
75 self.variant = 'Threaded' 75 self.variant = 'Threaded'
76 76
77 def attachThread(self, target=None, args=None, kwargs=None, mainThread=0): 77 def attachThread(self, target=None, args=None, kwargs=None,
78 mainThread=False):
78 """ 79 """
79 Public method to setup a thread for DebugClient to debug. 80 Public method to setup a thread for DebugClient to debug.
80 81
81 If mainThread is non-zero, then we are attaching to the already 82 If mainThread is True, then we are attaching to the already
82 started mainthread of the app and the rest of the args are ignored. 83 started mainthread of the app and the rest of the args are ignored.
83 84
84 @param target the start function of the target thread (i.e. the 85 @param target the start function of the target thread (i.e. the
85 user code) 86 user code)
86 @param args arguments to pass to target 87 @param args arguments to pass to target
87 @param kwargs keyword arguments to pass to target 88 @param kwargs keyword arguments to pass to target
88 @param mainThread non-zero, if we are attaching to the already 89 @param mainThread True, if we are attaching to the already
89 started mainthread of the app 90 started mainthread of the app
90 @return The identifier of the created thread 91 @return identifier of the created thread
91 """ 92 """
92 try: 93 try:
93 self.lockClient() 94 self.lockClient()
94 newThread = DebugThread(self, target, args, kwargs, mainThread) 95 newThread = DebugThread(self, target, args, kwargs, mainThread)
95 ident = -1 96 ident = -1
121 except KeyError: 122 except KeyError:
122 pass 123 pass
123 finally: 124 finally:
124 self.unlockClient() 125 self.unlockClient()
125 126
126 def lockClient(self, blocking=1): 127 def lockClient(self, blocking=True):
127 """ 128 """
128 Public method to acquire the lock for this client. 129 Public method to acquire the lock for this client.
129 130
130 @param blocking flag to indicating a blocking lock 131 @param blocking flag to indicating a blocking lock
132 @type bool
131 @return flag indicating successful locking 133 @return flag indicating successful locking
134 @rtype bool
132 """ 135 """
133 if blocking: 136 if blocking:
134 self.clientLock.acquire() 137 self.clientLock.acquire()
135 else: 138 else:
136 return self.clientLock.acquire(blocking) 139 return self.clientLock.acquire(blocking)
177 def set_quit(self): 180 def set_quit(self):
178 """ 181 """
179 Public method to do a 'set quit' on all threads. 182 Public method to do a 'set quit' on all threads.
180 """ 183 """
181 try: 184 try:
182 locked = self.lockClient(0) 185 locked = self.lockClient(False)
183 try: 186 try:
184 for key in self.threads.keys(): 187 for key in self.threads.keys():
185 self.threads[key].set_quit() 188 self.threads[key].set_quit()
186 except Exception: 189 except Exception:
187 pass 190 pass

eric ide

mercurial