home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import threading
- import inspect
- import ctypes
-
- def _async_raise(tid, exctype):
- if not inspect.isclass(exctype):
- raise TypeError('Only types can be raised (not instances)')
- inspect.isclass(exctype)
- res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
- if res == 0:
- raise ValueError('invalid thread id')
- res == 0
- if res != 1:
- ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, 0)
- raise SystemError('PyThreadState_SetAsyncExc failed')
- res != 1
-
-
- class ThreadEx(threading.Thread):
-
- def _get_my_tid(self):
- if not self.isAlive():
- raise threading.ThreadError('the thread is not active')
- self.isAlive()
- if hasattr(self, '_thread_id'):
- return self._thread_id
- for tid, tobj in threading._active.items():
- if tobj is self:
- self._thread_id = tid
- return tid
-
- raise AssertionError("could not determine the thread's id")
-
-
- def raise_exc(self, exctype):
- _async_raise(self._get_my_tid(), exctype)
-
-
- def kill(self):
- self.raise_exc(SystemExit)
-
-
-