zoukankan      html  css  js  c++  java
  • Python定时调度--多任务同一时间开始跑 scheduler.enterabs

    Event Priorities

    If more than one event is scheduled for the same time their priority values are used to determine the order they are run.

    import sched
    import time
    
    scheduler = sched.scheduler(time.time, time.sleep)
    
    def print_event(name):
        print 'EVENT:', time.time(), name
    
    now = time.time()
    print 'START:', now
    scheduler.enterabs(now+2, 2, print_event, ('first',))
    scheduler.enterabs(now+2, 1, print_event, ('second',))
    
    scheduler.run()

    This example needs to ensure that they are scheduled for the exact same time, so the enterabs() method is used instead of enter(). The first argument to enterabs() is the time to run the event, instead of the amount of time to delay. The second argument is the priority value, smaller number is more prioriable.

    $ python sched_priority.py
    
    START: 1361446608.62
    EVENT: 1361446610.62 second
    EVENT: 1361446610.62 first
  • 相关阅读:
    浏览器返回按钮不会触发onLoad事件
    js常用方法
    清除浮动
    Hbuilder快捷键
    页面跳转
    castapp.js颜色配置
    mui学习
    css 特殊使用技巧
    mui框架如何实现页面间传值
    从0到千万级访问量网站架构演变史
  • 原文地址:https://www.cnblogs.com/100thMountain/p/4745835.html
Copyright © 2011-2022 走看看