From e4498664bb3b25500fa4dc88f8343d483abe32f6 Mon Sep 17 00:00:00 2001 From: Daniel Folkinshteyn Date: Sun, 8 Aug 2010 00:39:51 -0400 Subject: [PATCH] Fix error handling for subprocesses. --- src/commands.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/commands.py b/src/commands.py index 674b631f4..5182ea582 100644 --- a/src/commands.py +++ b/src/commands.py @@ -81,8 +81,11 @@ def process(f, *args, **kwargs): q = multiprocessing.Queue() def newf(f, q, *args, **kwargs): - r = f(*args, **kwargs) - q.put(r) + try: + r = f(*args, **kwargs) + q.put(r) + except Exception as e: + q.put(e) targetArgs = (f, q,) + args p = callbacks.CommandProcess(target=newf, args=targetArgs, kwargs=kwargs) @@ -95,6 +98,8 @@ def process(f, *args, **kwargs): v = q.get(block=False) except Queue.Empty: v = "Nothing returned." + if isinstance(v, Exception): + v = "Error: " + str(v) return v class UrlSnarfThread(world.SupyThread):