From 2f14c122e4337f7b20560ebc59094e45c653d0df Mon Sep 17 00:00:00 2001 From: Ryan Branche Date: Thu, 20 Feb 2020 16:14:25 -0800 Subject: [PATCH] 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. --- django_q/cluster.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/django_q/cluster.py b/django_q/cluster.py index c6bffae..17d78ab 100644 --- a/django_q/cluster.py +++ b/django_q/cluster.py @@ -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]