Mercurial and Git clients can push and pull from this alias URL to interact with this repository. You can change to which repository an alias points by going to the Aliases link on the project page.
# Interuptible threads## http://sebulba.wikispaces.com/recipe+thread2## This software may be used and distributed according to the terms of the# GNU General Public License version 2, incorporated herein by reference.importthreadingimportinspectimportctypesdef_async_raise(tid,exctype): """raises the exception, performs cleanup if needed"""
if not inspect.isclass(exctype):
raise TypeError("Only types can be raised (not instances)")
- res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
+ res = ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), ctypes.py_object(exctype))
if res == 0:
raise ValueError("invalid thread id")
elif res != 1:
# """if it returns a number greater than one, you're in trouble,# and you should call it again with exc=NULL to revert the effect"""ctypes.pythonapi.PyThreadState_SetAsyncExc(tid,0)raiseSystemError("PyThreadState_SetAsyncExc failed")classThread(threading.Thread):def_get_my_tid(self):"""determines this (self's) thread id"""ifnotself.isAlive():raisethreading.ThreadError("the thread is not active")# do we have it cached?ifhasattr(self,"_thread_id"):returnself._thread_id# no, look for it in the _active dictfortid,tobjinthreading._active.items():iftobjisself:self._thread_id=tidreturntidraiseAssertionError("could not determine the thread's id")defraise_exc(self,exctype):"""raises the given exception type in the context of this thread"""_async_raise(self._get_my_tid(),exctype)defterminate(self):"""raises SystemExit in the context of the given thread, which should cause the thread to exit silently (unless caught)"""self.raise_exc(SystemExit)
Attach a Trello Card
Add a tag
Your session has expired
You are no longer logged in. Please log in and try your request again.
Filter RSS Feed
This RSS feed URL allows you to see the contents of your current filter using any feed reader.
This link includes a special authentication token. If you share the URL with anyone else, they can see this RSS feed's activity. You can disable these tokens when needed.
Your current filter is unsaved; changing it won't affect this RSS feed.