mirror of
https://github.com/inventree/InvenTree.git
synced 2026-09-09 22:30:17 +00:00
Exception handling for data outputs (#12797)
This commit is contained in:
@@ -32,10 +32,24 @@ def print_reports(
|
||||
try:
|
||||
template = ReportTemplate.objects.get(pk=template_id)
|
||||
output = DataOutput.objects.get(pk=output_id)
|
||||
except DataOutput.DoesNotExist:
|
||||
# The DataOutput may have already been consumed and deleted by the time
|
||||
# this task runs (e.g. if the background worker redelivered the task)
|
||||
logger.info(
|
||||
'DataOutput %s no longer exists - skipping print_reports task', output_id
|
||||
)
|
||||
return
|
||||
except Exception:
|
||||
log_error('report.tasks.print_reports')
|
||||
return
|
||||
|
||||
if output.complete:
|
||||
# This task has already been processed (e.g. a redelivered/duplicate task) - skip it
|
||||
logger.info(
|
||||
'DataOutput %s is already complete - skipping print_reports task', output_id
|
||||
)
|
||||
return
|
||||
|
||||
# Fetch user information
|
||||
user = None
|
||||
|
||||
@@ -86,10 +100,24 @@ def print_labels(
|
||||
try:
|
||||
template = LabelTemplate.objects.get(pk=template_id)
|
||||
output = DataOutput.objects.get(pk=output_id)
|
||||
except DataOutput.DoesNotExist:
|
||||
# The DataOutput may have already been consumed and deleted by the time
|
||||
# this task runs (e.g. if the background worker redelivered the task)
|
||||
logger.info(
|
||||
'DataOutput %s no longer exists - skipping print_labels task', output_id
|
||||
)
|
||||
return
|
||||
except Exception:
|
||||
log_error('report.tasks.print_labels')
|
||||
return
|
||||
|
||||
if output.complete:
|
||||
# This task has already been processed (e.g. a redelivered/duplicate task) - skip it
|
||||
logger.info(
|
||||
'DataOutput %s is already complete - skipping print_labels task', output_id
|
||||
)
|
||||
return
|
||||
|
||||
# Fetch user information
|
||||
user = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user