mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 20:16:44 +00:00
Handle errors when offloading tasks
This commit is contained in:
parent
0a40c253a5
commit
c848ca8d44
@ -64,9 +64,7 @@ def offload_task(taskname, *args, force_sync=False, **kwargs):
|
||||
|
||||
try:
|
||||
from django_q.tasks import AsyncTask
|
||||
except (AppRegistryNotReady):
|
||||
logger.warning("Could not offload task - app registry not ready")
|
||||
return
|
||||
|
||||
import importlib
|
||||
from InvenTree.status import is_worker_running
|
||||
|
||||
@ -110,6 +108,12 @@ def offload_task(taskname, *args, force_sync=False, **kwargs):
|
||||
# Workers are not running: run it as synchronous task
|
||||
_func(*args, **kwargs)
|
||||
|
||||
except (AppRegistryNotReady):
|
||||
logger.warning(f"Could not offload task '{taskname}' - app registry not ready")
|
||||
return
|
||||
except (OperationalError, ProgrammingError):
|
||||
logger.warning(f"Could not offload task '{taskname}' - database not ready")
|
||||
|
||||
|
||||
def heartbeat():
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user