How to start a long-running process from a Django view?

时光毁灭记忆、已成空白 提交于 2019-11-28 18:52:07

I don't know if this will be suitable for your case, nevertheless here is what I do: I use a task queue (via a django model); when the view is called, it enters a new record in the tasks and redirects happily. Tasks in turn are executed by cron on a regular basis independently from django.

Edit: cron calls the relevant (and custom) django command to execute the task.

First of all - try to using cron for you task, as early say shanyu.

If it doesn't suit you - then try to use CeleryProject, for task Queue for Django. For working it uses RabbitMQ. And here is a little overview for simple using of basing futures

http://code.google.com/p/django-command-extensions/wiki/JobsScheduling

Is a nice library that that you can use to accomplish this task.

Take a look at the code in kronos.py to see one solution to this problem.

http://www.razorvine.net/download/kronos.py

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