2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-02 05:26:45 +00:00

use a function if it was passed

This commit is contained in:
Matthias Mair 2022-05-16 18:30:37 +02:00
parent 7fc408cf60
commit 763cd13b7c

View File

@ -74,10 +74,6 @@ def offload_task(taskname, *args, force_sync=False, **kwargs):
except (OperationalError, ProgrammingError): # pragma: no cover
logger.warning(f"Could not offload task '{taskname}' - database not ready")
# make sure the taskname is a string
if not isinstance(taskname, str):
taskname = str(taskname)
if is_worker_running() and not force_sync: # pragma: no cover
# Running as asynchronous task
try:
@ -86,6 +82,11 @@ def offload_task(taskname, *args, force_sync=False, **kwargs):
except ImportError:
logger.warning(f"WARNING: '{taskname}' not started - Function not found")
else:
if isinstance(taskname, function):
# function was passed - use that
_func = taskname
else:
# Split path
try:
app, mod, func = taskname.split('.')