mirror of
https://github.com/inventree/InvenTree.git
synced 2025-05-02 13:28:49 +00:00
use a function if it was passed
This commit is contained in:
parent
7fc408cf60
commit
763cd13b7c
@ -74,10 +74,6 @@ def offload_task(taskname, *args, force_sync=False, **kwargs):
|
|||||||
except (OperationalError, ProgrammingError): # pragma: no cover
|
except (OperationalError, ProgrammingError): # pragma: no cover
|
||||||
logger.warning(f"Could not offload task '{taskname}' - database not ready")
|
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
|
if is_worker_running() and not force_sync: # pragma: no cover
|
||||||
# Running as asynchronous task
|
# Running as asynchronous task
|
||||||
try:
|
try:
|
||||||
@ -86,6 +82,11 @@ def offload_task(taskname, *args, force_sync=False, **kwargs):
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
logger.warning(f"WARNING: '{taskname}' not started - Function not found")
|
logger.warning(f"WARNING: '{taskname}' not started - Function not found")
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
if isinstance(taskname, function):
|
||||||
|
# function was passed - use that
|
||||||
|
_func = taskname
|
||||||
|
else:
|
||||||
# Split path
|
# Split path
|
||||||
try:
|
try:
|
||||||
app, mod, func = taskname.split('.')
|
app, mod, func = taskname.split('.')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user