zoukankan      html  css  js  c++  java
  • python apscheduler的使用

    from apscheduler.schedulers.blocking import BlockingScheduler
    from datetime import datetime
    def my_job(x=None): print 'hello world'   print x sched = BlockingScheduler() sched.add_job(my_job, 'interval', seconds=5) #每5秒执行一次 sched.start()
    ############
    
    







    apscheduler 官网http://pypi.python.org/pypi/APScheduler/2.0.3

    from apscheduler.schedulers.blocking import BlockingScheduler
    def my_job(x=None):
    print x

    sched = BlockingScheduler()
    sched.add_job(my_job, 'interval', seconds=2, start_date='2017-02-22 17:46:59',args=['123'])#
    start_date开始没2秒执行一次

    interval 间隔调度

    它的参数如下:

    weeks(int) – number of weeks to wait

    days(int) – number of days to wait

    hours(int) – number of hours to wait

    minutes(int) – number of minutes to wait

    seconds(int) – number of seconds to wait

    start_date(datetime|str) – starting point for the interval calculation

    end_date(datetime|str) – latest possible date/time to trigger on

    更多:http://www.tuicool.com/articles/FbeIRzI

    http://www.cnblogs.com/timliucn/p/5894361.html

    $ pip install schedule
    import schedule
    import time
    
    def job():
        print("I'm working...")
    
    schedule.every(10).minutes.do(job)
    schedule.every().hour.do(job)
    schedule.every().day.at("10:30").do(job)
    schedule.every().monday.do(job)
    schedule.every().wednesday.at("13:15").do(job)
    # schedule.every(1).seconds.do(job)
    while True: schedule.run_pending() time.sleep(1)

    https://pypi.python.org/pypi/schedule/官网地址
  • 相关阅读:
    RAID技术
    敏捷开发
    如何写出高质量的代码?现在知道还不晚
    Java大型互联网架构技术经验
    Chrome精品插件
    2018 java BAT最新面试宝典
    Java成神之路(2018版)
    三分钟读懂摘要算法
    我的Mac应用清单
    事务隔离级别
  • 原文地址:https://www.cnblogs.com/wanghaonull/p/6430340.html
Copyright © 2011-2022 走看看