5 ms·
Don't know what you did wrong, but you should be able to catch exceptions at their appropriate level and shut down gracefully.
by mixmastamyk 9y ago
Don't know what you did wrong, but you should be able to catch exceptions at their appropriate level and shut down gracefully.
- icegreentea2 9y agomultiprocessing was designed to mirror the threading library... so the exceptions are specifically set up not to cross thread/process boundaries. But the same strategies to handle multithreaded exceptions and keyboardinterrupt should apply. If you want the child processes to shutdown when the main process goes down, you should be able to just set .daemon = True on the process objects before you start them. If you want exceptions in the children thread to propagate up to the main thread and then handle, looks like you'd just need to send the exception across a queue or something in multiproccessing. In the new futures library, your future (wrapping the process) has a return value property you can try to access. If the child process ran into an exception, that exception would be raised in the main process when you tried to access that return value.
- rcthompson 9y agoI know it should be possible, but I've never figured out how to do it, nor have I ever seen any example code using multiprocessing that does it. If you know of some example code that properly catches and handles exceptions in any process, I'd love to see it.