147 def dumpThreadList(self): |
147 def dumpThreadList(self): |
148 """ |
148 """ |
149 Public method to send the list of threads. |
149 Public method to send the list of threads. |
150 """ |
150 """ |
151 self.updateThreadList() |
151 self.updateThreadList() |
|
152 |
152 threadList = [] |
153 threadList = [] |
153 if len(self.threads) > 1: |
154 currentId = _thread.get_ident() |
154 currentId = _thread.get_ident() |
155 # update thread names set by user (threading.setName) |
155 # update thread names set by user (threading.setName) |
156 threadNames = {t.ident: t.getName() for t in threading.enumerate()} |
156 threadNames = {t.ident: t.getName() for t in threading.enumerate()} |
157 |
157 |
158 for threadId, thd in self.threads.items(): |
158 for threadId, thd in self.threads.items(): |
159 d = {"id": threadId} |
159 d = {"id": threadId} |
160 try: |
160 try: |
161 d["name"] = threadNames.get(threadId, thd.name) |
161 d["name"] = threadNames.get(threadId, thd.name) |
162 d["broken"] = thd.isBroken |
162 d["broken"] = thd.isBroken |
163 d["except"] = thd.isException |
163 d["except"] = thd.isException |
164 except Exception: |
164 except Exception: |
165 d["name"] = 'UnknownThread' |
165 d["name"] = 'UnknownThread' |
166 d["broken"] = False |
166 d["broken"] = False |
167 d["except"] = False |
167 d["except"] = False |
168 |
168 |
|
169 threadList.append(d) |
|
170 else: |
|
171 currentId = -1 |
|
172 d = {"id": -1} |
|
173 d["name"] = "MainThread" |
|
174 d["broken"] = self.isBroken |
|
175 d["except"] = self.isException |
|
176 threadList.append(d) |
169 threadList.append(d) |
177 |
170 |
178 self.sendJsonCommand("ResponseThreadList", { |
171 self.sendJsonCommand("ResponseThreadList", { |
179 "currentID": currentId, |
172 "currentID": currentId, |
180 "threadList": threadList, |
173 "threadList": threadList, |