From 2feaddba08f5ba1b6cfda5e257daaca44a2369a1 Mon Sep 17 00:00:00 2001 From: Daniel Folkinshteyn Date: Fri, 12 Aug 2011 16:28:50 -0400 Subject: [PATCH] src/commands.py: make subprocesses raise an error on timeout, rather than return a string --- src/commands.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/commands.py b/src/commands.py index 5182ea582..478dfcc56 100644 --- a/src/commands.py +++ b/src/commands.py @@ -69,6 +69,10 @@ def thread(f): f(self, irc, msg, args, *L, **kwargs) return utils.python.changeFunctionName(newf, f.func_name, f.__doc__) +class ProcessTimeoutError(Exception): + """Gets raised when a process is killed due to timeout.""" + pass + def process(f, *args, **kwargs): """Runs a function in a subprocess. @@ -93,7 +97,7 @@ def process(f, *args, **kwargs): p.join(timeout) if p.is_alive(): p.terminate() - return "%s aborted due to timeout." % (p.name,) + raise ProcessTimeoutError, "%s aborted due to timeout." % (p.name,) try: v = q.get(block=False) except Queue.Empty: