Skip to content

Commit

Permalink
fix: reload before saving on reconnect (#26534) (#26536)
Browse files Browse the repository at this point in the history
The doc we have might be "in future".

(cherry picked from commit 9e9e72b)

Co-authored-by: Ankush Menat <ankush@frappe.io>
  • Loading branch information
mergify[bot] and ankush committed May 22, 2024
1 parent 446780c commit b2d17c1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frappe/core/doctype/prepared_report/prepared_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ def generate_report(prepared_report):

instance.status = "Completed"
except Exception:
instance.status = "Error"
instance.error_message = frappe.get_traceback(with_context=True)
_save_instance(instance) # we need to ensure that error gets stored
# we need to ensure that error gets stored
_save_error(instance, error=frappe.get_traceback(with_context=True))

instance.report_end_time = frappe.utils.now()
instance.save(ignore_permissions=True)
Expand All @@ -102,7 +101,10 @@ def update_job_id(prepared_report, job_id):


@dangerously_reconnect_on_connection_abort
def _save_instance(instance):
def _save_error(instance, error):
instance.reload()
instance.status = "Error"
instance.error_message = error
instance.save(ignore_permissions=True)


Expand Down

0 comments on commit b2d17c1

Please sign in to comment.