Skip to content

Commit

Permalink
fix(background_jobs): Pass retval in execute_job
Browse files Browse the repository at this point in the history
  • Loading branch information
gavindsouza committed Feb 10, 2023
1 parent 55b31fc commit 83f3cf1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion frappe/utils/background_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def run_doc_method(doctype, name, doc_method, **kwargs):

def execute_job(site, method, event, job_name, kwargs, user=None, is_async=True, retry=0):
"""Executes job in a worker, performs commit/rollback and logs if there is any error"""
retval = None
if is_async:
frappe.connect(site)
if os.environ.get("CI"):
Expand All @@ -173,7 +174,7 @@ def execute_job(site, method, event, job_name, kwargs, user=None, is_async=True,
frappe.call(before_job_task, method=method_name, kwargs=kwargs)

try:
method(**kwargs)
retval = method(**kwargs)

except (frappe.db.InternalError, frappe.RetryBackgroundJobError) as e:
frappe.db.rollback()
Expand Down Expand Up @@ -204,6 +205,7 @@ def execute_job(site, method, event, job_name, kwargs, user=None, is_async=True,

else:
frappe.db.commit()
return retval

finally:
for after_job_task in frappe.get_hooks("after_job"):
Expand Down

0 comments on commit 83f3cf1

Please sign in to comment.