mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
offload_task: log errors (#6620)
- Log any errors raised during offload_task
This commit is contained in:
parent
c6f43efef8
commit
b19def7a1e
@ -180,6 +180,8 @@ def offload_task(
|
||||
Returns:
|
||||
bool: True if the task was offloaded (or ran), False otherwise
|
||||
"""
|
||||
from InvenTree.exceptions import log_error
|
||||
|
||||
try:
|
||||
import importlib
|
||||
|
||||
@ -213,6 +215,7 @@ def offload_task(
|
||||
return False
|
||||
except Exception as exc:
|
||||
raise_warning(f"WARNING: '{taskname}' not offloaded due to {str(exc)}")
|
||||
log_error('InvenTree.offload_task')
|
||||
return False
|
||||
else:
|
||||
if callable(taskname):
|
||||
@ -233,6 +236,7 @@ def offload_task(
|
||||
try:
|
||||
_mod = importlib.import_module(app_mod)
|
||||
except ModuleNotFoundError:
|
||||
log_error('InvenTree.offload_task')
|
||||
raise_warning(
|
||||
f"WARNING: '{taskname}' not started - No module named '{app_mod}'"
|
||||
)
|
||||
@ -249,6 +253,7 @@ def offload_task(
|
||||
if not _func:
|
||||
_func = eval(func) # pragma: no cover
|
||||
except NameError:
|
||||
log_error('InvenTree.offload_task')
|
||||
raise_warning(
|
||||
f"WARNING: '{taskname}' not started - No function named '{func}'"
|
||||
)
|
||||
@ -258,6 +263,7 @@ def offload_task(
|
||||
try:
|
||||
_func(*args, **kwargs)
|
||||
except Exception as exc:
|
||||
log_error('InvenTree.offload_task')
|
||||
raise_warning(f"WARNING: '{taskname}' not started due to {str(exc)}")
|
||||
return False
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user