| 13 | raise SystemError("PyThreadState_SetAsyncExc failed") |
| 14 | |
| 15 | class Thread(threading.Thread): |
| 16 | def raise_exc(self, excobj): |
| 17 | assert self.isAlive(), "thread must be started" |
| 18 | for tid, tobj in threading._active.items(): |
| 19 | if tobj is self: |
| 20 | _async_raise(tid, excobj) |
| 21 | return |
| 22 | |
| 23 | # the thread was alive when we entered the loop, but was not found |
| 24 | # in the dict, hence it must have been already terminated. should we raise |
| 25 | # an exception here? silently ignore? |
| 26 | |
| 27 | def terminate(self): |
| 28 | # must raise the SystemExit type, instead of a SystemExit() instance |
| 29 | # due to a bug in PyThreadState_SetAsyncExc |
| 30 | self.raise_exc(SystemExit) |
no outgoing calls
no test coverage detected