multiprocessing just mimicks the threading module here, see http://bugs.python.org/issue1230540 . Why do you need excepthook in the first place?
You can perfectly simulate it by wrapping the root method (target in
your example) in a try .. catch:
import multiprocessing
import sys
def printErrors(func):
def wrapped(*args, **kwargs):
try:
func()
except:
print ('except: ', sys.exc_info())
return wrapped
@printErrors
def target():
raise ValueError()
if __name__ == '__main__':
p = multiprocessing.Process(target=target)
p.start()
p.join()
# try it here in main
target()
Cheers,
Philipp
On 06/12/2012 11:02 PM, Dave Cook wrote:
> Why doesn't my excepthook get called in the child process?
>
> import sys
> import multiprocessing as mp
>
> def target():
> name = mp.current_process().name
> def exceptHook(*args):
> print 'exceptHook:', name, args
> sys.excepthook = exceptHook
> raise ValueError
>
> if __name__=='__main__':
> p = mp.Process(target=target)
> p.start()
> p.join()
> # try it here in main
> target()
>
> Thanks,
> Dave Cook
signature.asc
Description: OpenPGP digital signature
-- http://mail.python.org/mailman/listinfo/python-list
