为龙卷风呼喊
tornado-crontab的Python项目详细描述
tornado crontab是一个库,它可以生成类似crontab的任务应用程序。
安装
自动安装:
$ pip install tornado-crontab
torando crontab列在PyPI中,可以与pip或easy_install一起安装。
手动安装:
$ git clone https://github.com/gaujin/tornado-crontab.git $ cd tornado-crontab $ python setup.py install
tornado crontab源代码是hosted on GitHub
用法
下面是“每分钟一次”任务应用程序的示例:
from __future__ import print_function import functools import tornado.ioloop import tornado_crontab def hello_crontab(value): print("Hello, {0}".format(value)) if __name__ == "__main__": _func = functools.partial(hello_crontab, *["crontab"]) tornado_crontab.CronTabCallback(_func, "* * * * *").start() tornado.ioloop.IOLoop.current().start()
装饰风格的任务应用程序:
from __future__ import print_function import tornado.ioloop from tornado_crontab import crontab @crontab("* * * * *") def hello_crontab(value): print("Hello, {0}".format(value)) if __name__ == "__main__": hello_crontab("crontab") tornado.ioloop.IOLoop.current().start()
先决条件
Tornado Crontab 0.4.x或更早版本在Tornado 4.x或更早版本上运行。
io_循环参数的未来策略
io_loop函数和构造函数的参数对于0.4.0是不推荐使用的,对于0.5.0是删除的。
关于此策略基于Tornado中已指示的策略,Tornado Crontab也制定了相同的策略。
许可证
- Tornado Crontab许可证位于MIT license。
- Tornado is licensed under the Apache license。
- crontab is licensed under the LGPL license version 2.1。
具体条款见许可文件。