My django app is running on an nginx/uwsgi stack. My goal is to start a python script which runs independently from the web server. By hitting a endpoint on django, it would thus fire off a non blocking script.
I've looked into using python subprocess/Popen - i'm just not sure if the script is still running on the web server or not via subprocess.Popen()
asked Apr 6, 2015 at 19:46
Hacking Life
3,3832 gold badges21 silver badges20 bronze badges
-
You could use Twisted, but you'd have to do a bit of wizardry with the Crochet library. It really depends on what you're trying to do. But if you're simply trying to run a script in a different process, you can just use Multiprocessing.notorious.no– notorious.no2015年04月06日 19:53:31 +00:00Commented Apr 6, 2015 at 19:53
-
Well, you could use celery.readthedocs.org/en/latest, that integrates nicely with Django. The asynchronous task would then run the background, and commit its potential result to a backend.Balthazar Rouberol– Balthazar Rouberol2015年04月06日 19:59:01 +00:00Commented Apr 6, 2015 at 19:59
1 Answer 1
This is exactly what Celery is for. You should use that.
answered Apr 6, 2015 at 20:52
Daniel Roseman
602k68 gold badges911 silver badges924 bronze badges
Sign up to request clarification or add additional context in comments.
2 Comments
Hacking Life
So celery can run background tasks that wont die even if a uwsgi process serving django is running on dies?
Hacking Life
After some doc reading - I didn't realize celery was separately daemonized, thus exactly what I needed. When using uwsgi however, I did find their Mules concept to be on par with celery.
lang-py