##// END OF EJS Templates
wxIpython 0.8 initial import...
laurent.dufrechou -
Show More

The requested changes are too big and content was truncated. Show full diff

1 NO CONTENT: new file 100644
@@ -0,0 +1,45 b''
1 import threading
2 import inspect
3 import ctypes
4
5
6 def _async_raise(tid, exctype):
7 """raises the exception, performs cleanup if needed"""
8 if not inspect.isclass(exctype):
9 raise TypeError("Only types can be raised (not instances)")
10 res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
11 if res == 0:
12 raise ValueError("invalid thread id")
13 elif res != 1:
14 # """if it returns a number greater than one, you're in trouble,
15 # and you should call it again with exc=NULL to revert the effect"""
16 ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, 0)
17 raise SystemError("PyThreadState_SetAsyncExc failed")
18
19
20 class Thread(threading.Thread):
21 def _get_my_tid(self):
22 """determines this (self's) thread id"""
23 if not self.isAlive():
24 raise threading.ThreadError("the thread is not active")
25
26 # do we have it cached?
27 if hasattr(self, "_thread_id"):
28 return self._thread_id
29
30 # no, look for it in the _active dict
31 for tid, tobj in threading._active.items():
32 if tobj is self:
33 self._thread_id = tid
34 return tid
35
36 raise AssertionError("could not determine the thread's id")
37
38 def raise_exc(self, exctype):
39 """raises the given exception type in the context of this thread"""
40 _async_raise(self._get_my_tid(), exctype)
41
42 def kill(self):
43 """raises SystemExit in the context of the given thread, which should
44 cause the thread to exit silently (unless caught)"""
45 self.raise_exc(SystemExit)
1 NO CONTENT: new file 100644
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: new file 100644
The requested commit or file is too big and content was truncated. Show full diff
General Comments 0
You need to be logged in to leave comments. Login now