8239:59a9a658618c | 8240:93b8a353c4bf |
---|---|
7 Module implementing an import hook patching thread modules to get debugged too. | 7 Module implementing an import hook patching thread modules to get debugged too. |
8 """ | 8 """ |
9 | 9 |
10 import os | 10 import os |
11 import sys | 11 import sys |
12 import contextlib | |
12 | 13 |
13 import _thread | 14 import _thread |
14 import threading | 15 import threading |
15 | 16 |
16 from DebugBase import DebugBase | 17 from DebugBase import DebugBase |
93 @param threadId id of the DebugThread that has exited | 94 @param threadId id of the DebugThread that has exited |
94 @type int | 95 @type int |
95 """ | 96 """ |
96 self.lockClient() | 97 self.lockClient() |
97 try: | 98 try: |
98 del self.threads[threadId] | 99 with contextlib.suppress(KeyError): |
99 except KeyError: | 100 del self.threads[threadId] |
100 pass | |
101 finally: | 101 finally: |
102 self.unlockClient() | 102 self.unlockClient() |
103 | 103 |
104 def lockClient(self, blocking=True): | 104 def lockClient(self, blocking=True): |
105 """ | 105 """ |
114 | 114 |
115 def unlockClient(self): | 115 def unlockClient(self): |
116 """ | 116 """ |
117 Public method to release the lock for this client. | 117 Public method to release the lock for this client. |
118 """ | 118 """ |
119 try: | 119 with contextlib.suppress(RuntimeError): |
120 self.clientLock.release() | 120 self.clientLock.release() |
121 except RuntimeError: | |
122 pass | |
123 | 121 |
124 def setCurrentThread(self, threadId): | 122 def setCurrentThread(self, threadId): |
125 """ | 123 """ |
126 Public method to set the current thread. | 124 Public method to set the current thread. |
127 | 125 |