如何在python中实现时间事件计划程序? [英] How to implement time event scheduler in python?
问题描述
在python中,如何实现在后台运行的线程(可能是在模块加载时),并在星期一至星期五上午10点至下午3点之间每分钟调用一次该函数.例如,应在以下位置调用该函数:
In python how to implement a thread which runs in the background (may be when the module loads) and calls the function every minute Monday to Friday 10 AM to 3 PM. For example the function should be called at:
上午10:01 上午10:02 上午10:03 . . 下午2:59
10:01 AM 10:02 AM 10:03 AM . . 2:59 PM
有指针吗?
环境:Django
谢谢
推荐答案
Django是一个服务器应用程序,仅对外部事件做出反应.
Django is a server application, which only reacts to external events.
您应该使用诸如 cron 之类的调度程序来创建调用django应用程序的事件,该事件可以调用管理子命令或在某些特殊页面上执行HTTP请求.
You should use a scheduler like cron to create events that call your django application, either calling a management subcommand or doing an HTTP request on some special page.
这篇关于如何在python中实现时间事件计划程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!