When sync=True, re-raise exceptions from the worker.

This commit adds code to detect if the task is running synchronously in
the worker and re-raise exceptions that were originally raised by the
underlying task function.
This commit is contained in:
Ryan Branche
2020-02-20 16:14:25 -08:00
parent 5351372fd9
commit 2f14c122e4

View File

@@ -424,6 +424,8 @@ def worker(task_queue, result_queue, timer, timeout=Conf.TIMEOUT):
result = (f"{e} : {traceback.format_exc()}", False)
if error_reporter:
error_reporter.report()
if task.get("sync", False):
raise
with timer.get_lock():
# Process result
task["result"] = result[0]