Tornado iLoop为人类提供的多线程/多进程任务调度程序驱动。

chronosp的Python项目详细描述


Chronos是由Tornado Ioloop驱动的多线程/多进程任务调度程序。

Install

使用以下命令安装扩展:

$ easy_install chronospy

或者,如果安装了pip:

$ pip install chronospy

或者从github克隆它,然后在shell中运行命令:

cd chronos # the path to the project
python setup.py install

Hello World

importtornadoimportchronosimportosimporturllib2deftest_process():print("process pid %s"%(os.getpid()))deftest(word):print("an other task, say '%s'"%(word))defsay():response=urllib2.urlopen('https://www.google.com/')html=response.read()print(html[:10])definit():# bind a ioloop or use default ioloopchronos.setup()# chronos.setup(tornado.ioloop.IOLoop())chronos.schedule('say',chronos.every_second(1),say)chronos.schedule('say2',chronos.every_second(1),test_process,once=True,process=True)chronos.schedule('say3',chronos.every_second(1),lambda:test("test3"))chronos.start(True)if__name__=='__main__':init()

API

setup

设置(IO U循环=无)

绑定IO_循环或使用默认IOloop。

schedule

计划(名称,计时器,func,once=false,start=false,process=false,max_executor=5)

将任务添加到Chronos:

name:uniqe task name,
timer:every timer object
func:the task function
once:set True will run only once time.
start:when chronos start and schedule a new task, if set to True will add to Tornado IOLoop and schedule to run at time.
process:if process is True, then the job will run in on a procees, otherwise defaultly running in thread.
max_executor:the max threads(or processes) to run a task.

remove_task

删除任务(任务名称)

停止并从Chronos中删除任务

start_task

开始任务(任务名称)

在Chronos中启动任务

stop_task

停止任务(任务名称)

在Chronos中停止任务

start

开始(start_ioloop=false)

在ioloop中添加任务,如果在tornado web服务器中使用chronos,则可以将start_ioloop设置为“false”,然后稍后启动自定义ioloop。

stop

停止(停止ioloop=false,清除=true)

停止ioloop中的任务

stop_ioloop:will stop the ioloop if set to “True”.
clear:will remove tasks from chrons if set to “True”.

how to use every tools

every_second

设置运行作业的平均秒数:

every_second(5) # run job every 5 seconds

every_at

设置每小时或每分钟运行一个作业:

every_at(hour=1, minute=10, second=0) # run at 01:10:00 every day
every_at(minute=10, second=0) # run at run at 10 mintue every hour

every

every(10).minutesevery().hourevery().day.at("10:30")every().mondayevery().wednesday.at("13:15")

LICENSE

Copyright (C) 2015 Thomas Huang

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java在一个问题被连续正确回答三次/并添加差异后,我如何将程序循环回开始   Java中未实例化的匿名类   java如何在Android中录制视频,只允许横向模式和最长时间录制时间   java从另一个活动发送实时消息   多线程java线程和互斥   java禁用Spring安全日志   JAVA伊奥。StreamCorruptedException:在与子级和父级ProcessBuilder通信时写入子级中的标准输出时,流头无效   使用Java(HttpURLConnection)对Restheart进行身份验证(对于Mongodb)   java如何解决Jenkins中的SAXParseException?   java为什么我需要mockito来测试Spring应用程序?   计算sin-cos和tan时缺乏精度(java)   java Hibernate。不同项目中相同一对一映射的不同行为   java图像滑块:如何使用JavaFX将图像放在另一个图像上   java Mockito在使用when时抛出NotAMockException   http Java servlet发送回响应