有向无环收集
项目描述
Dagather
Dagather(《d》irected 《a》cyclic 《g》ather)是一种规划和调度异步任务的新方法。任务是有组织的,每个任务都指定在其之前运行的任务。然后以拓扑顺序运行任务,确保每个操作都能尽快开始,而不必等待它不需要的例程。
from asyncio import sleep
from dagather import Dagather
foo = Dagather()
@foo.register
# add a new task to the task list
async def a():
await sleep(1)
return 12
@foo.register
async def b(a):
# we now specify that a is a requirement for this task,
# meaning that b will not be called until a has finished.
# during runtime, a's value will be the return value of the
# a task
assert a == 12
await sleep(2)
@foo.register
async def c(a):
await sleep(1)
return 'testing'
@foo.register
async def d():
await sleep(1)
@foo.register
async def e(d, c):
await sleep(1)
result = await foo()
# when foo is called, it runs each of its registered tasks
# as soon as all its dependencies are finished.
# once all the tasks are finished, it will return a dict
# mapping each task to its return value.
assert result == {
a: 12,
b: None,
c: 'testing',
d: None,
e: None
}
项目详细信息
下载文件
为您的平台下载文件。如果您不确定要选择哪个,请了解更多关于 安装包 的信息。
源分布
dagather-0.1.0.tar.gz (7.8 kB 查看哈希值)
构建分布
dagather-0.1.0-py3-none-any.whl (9.2 kB 查看哈希值)
关闭
dagather-0.1.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 9b986a9b35f24887abdbd572b664107a5f778c70e46c7f23019196b3a50397f4 |
|
MD5 | c3813d95a5cb50301d963528a88ba3f0 |
|
BLAKE2b-256 | c7eef62a9e6ff8056c3fe8282c6ca9b2cc08a03f536ef9760460a9d9e07166b4 |