If you're looking for a lightweight solution for just executing stuff in background rather than a full-blown task management system, take a look at django-utils. It includes, among other things, an @async function decorator that will make a function execute asynchronously in a separate thread.
Use it like this:
from djutils.decorators import async
@async
def load_data_async():
# this will be executed in a separate thread
load_data()
Then you can call either the load_data_async function
for background, or the normal load_data
function for blocking execution.
Just make sure to install a version before 2.0, since that lacks the @async decorator.
Note: If even installing django-utils would be too much, you can simply download it and include the few required files in your project.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…