mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-29 06:02:38 +01:00
Fix error handling for subprocesses.
This commit is contained in:
parent
89fd19ed7d
commit
e4498664bb
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user