python调度库
pyat的Python项目详细描述
Pyat
pyat是unix的python模拟程序,它在 指定的时间,可选地提供传递结果和 例外情况。
该接口旨在支持多种使用场景 包括带有主循环的同步应用程序,偶尔称为 函数、基于多线程/多处理的代码和异步框架 像扭曲或龙卷风。
要求
典型用法
import pyat.sync import time scheduler = pyat.sync.SynchronousScheduler() # ... etc ... background_task = None while True: # ... etc ... scheduler.poll() if foo == bar: # Do something in 10 seconds. background_task = scheduler.schedule( time.time() + 10, my_task, arg1, arg2, kwarg1=arg3) elif foo == baz: # Cancel task background_task.cancel() background_task = None elif (foo == quux) and (background_task is not None): # Check back on background task try: result = background_task.result # do something with result background_task = None except pyat.sync.NotExecutedYet: # A bit too early pass
状态
- 同步实现可以工作。