Running a subprocess in uwsgi application

送分小仙女□ 提交于 2020-01-02 10:06:34

问题


I'm writing a Django application, which needs to perform long async tasks. Initial idea was to start a subprocess from the view that does that job, and to monitor the progress in another views.

The idea works fine when application is started via manage.py runserver, but it doesn't when it is run under uwsgi. The child process is started, but after the view returns uwsgi waits for the child process end, which breaks the whole idea.

I can see the request details in the uwsgi log (number of bytes generated, etc), but the socket isn't closed, so the browser waits too.

I have seen other alternatives for running async tasks, e.g. celery, but so far I've spent more time trying to configure celery than I've spent for the task. If there's any other way, I'll be happy to hear how you solved it.


回答1:


http://uwsgi-docs.readthedocs.org/en/latest/ThingsToKnow.html

--close-on-exec is what you need




回答2:


I have found a good alternative: https://github.com/ui/django-rq , which is easy to install and configure, and it does the job correctly.

Original problem with subprocesses is still unclear though.



来源:https://stackoverflow.com/questions/17592692/running-a-subprocess-in-uwsgi-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!