devork

E pur si muove

Raising exceptions in threads

Saturday, June 06, 2009

It's not simply raising an exception in a thread that I want. I want to raise an exception in a thread from another thread. It's like sending signals to threads, only signals in pyhon can only be delivered to the main thread (for portability). But Python has a other asynchronous signaling system: exceptions.

I'd like to be able to do something like:

for t in threading.enumerate():
    thread.raise(MyAppDoesntWantYouAnymoreError)

Is this possible? Are there other ways to do this sort of thing?

Alternatively I might be happy with a fix for issue1856, but I do think it might be nice to be able to signal threads in an asynchronous way in any case.

3 comments:

New comments are not allowed.

Subscribe to: Post Comments (Atom)