Django, Python calling Python code without waiting for response?
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Realization
--
Chapters
00:00 Django, Python Calling Python Code Without Waiting For Response?
00:59 Accepted Answer Score 6
01:37 Answer 2 Score 0
01:59 Thank you
--
Full question
https://stackoverflow.com/questions/3806...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#python #django #longrunningprocesses
#avk47
ACCEPTED ANSWER
Score 6
Can't vouch for it because I haven't used it yet, but "Celery" does pretty much what you're asking for and was originally built specifically for Django.
Their example showing a simple task adding two numbers:
from celery.decorators import task
@task
def add(x, y):
    return x + y
You can execute the task in the background, or wait for it to finish:
>>> result = add.delay(8, 8)
>>> result.wait() # wait for and return the result
16
You'll probably need to install RabbitMQ also to get it working, so it might be more complicated of a solution than you're looking for, but it will achieve your goals.
ANSWER 2
Score 0
You want an asynchronous message manager. I've got a tutorial on integrating Gearman with Django. Any pickleable Python object can be sent to Gearman, which will do all the work and post the results wherever you want; the tutorial includes examples of posting back to the Django database (it also shows how to use the ORM outside of Django).