用twisted为未来安排任务(Scheduling tasks for the future
2012-06-04 13:52
423 查看
我们想再x秒后执行一个任务,可以使用twisted.internet.interfaces.IReactorTime: from twisted.internet import reactor def f(s): print "this will run 3.5 seconds after it was scheduled: %s" % s reactor.callLater(3.5, f, "hello, world") 如果想每x秒就重复执行一个任务,可以使用twisted.internet.task.LoopingCall: from twisted.internet import task def runEverySecond(): print "a second has passed" l = task.LoopingCall(runEverySecond) l.start(1.0) # call every second # l.stop() will stop the looping calls 如果想要取消一个已经安排的任务: from twisted.internet import reactor def f(): print "I'll never run." callID = reactor.callLater(5, f) callID.cancel() 翻译 -- Jerry Marx. |
相关文章推荐
- 用twisted为未来安排任务(Scheduling tasks for the future)
- 《未来的五种智力》(Five minds for the future)
- recording just for inquiry in the future
- ArcGIS API for Silverlight开发入门(5):任务外包——Tasks
- SpringBoot非官方教程 | 第十八篇: 定时任务(Scheduling Tasks)
- SpringBoot非官方教程 | 第十八篇: 定时任务(Scheduling Tasks)
- Technologies for the Wireless Future: Wireless World Research Forum, Volume 3
- Spring任务调度Scheduling Tasks
- The Plan for Future two years
- What is the Future for SharePoint?
- 实时SLAM的未来及与深度学习的比较The Future of Real-Time SLAM and “Deep Learning vs SLAM”
- [原创] 我的生活我安排,我的调度我做主!——介绍一个 日程安排/工作计划/任务调度 的Scheduling组件。(二)
- what to do for the future?
- Spring Boot 与 Kotlin 定时任务(Scheduling Tasks)
- [商业][思想]《免费 -- 商业的未来 Free The Future of a Radical Price》 -- 克里斯·安德森(美)
- Lesson 51:Predicting the future 预测未来
- Snapdragon 820 Deep Learning SDK Will Promise Better Privacy For The Future
- Scheduling Tasks定时任务
- BusinessTasks for Mac(任务管理工具)免激活版 v1.0.3破解版
- Clarifications on Flash Player for Mobile Browsers, the Flash Platform, and the Future of Flash[翻译练习]