mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 03:18:12 +08:00
Fix: handling exceptions inside job function (#51)
This commit is contained in:
+3
-10
@@ -485,19 +485,12 @@ def worker(
|
||||
try:
|
||||
res = f(*task["args"], **task["kwargs"])
|
||||
result = (res, True)
|
||||
except Exception:
|
||||
result = (
|
||||
_(
|
||||
"Could not process '%(func_name)s'. Check the location of the "
|
||||
"function and the args/kwargs."
|
||||
)
|
||||
% {"func_name": func_name},
|
||||
False,
|
||||
)
|
||||
except Exception as e:
|
||||
result = (f"{e} : {traceback.format_exc()}", False)
|
||||
if error_reporter:
|
||||
error_reporter.report()
|
||||
if task.get("sync", False):
|
||||
raise Exception(result)
|
||||
raise
|
||||
with timer.get_lock():
|
||||
# Process result
|
||||
task["result"] = result[0]
|
||||
|
||||
Reference in New Issue
Block a user