directed acyclic gather
Project description
Dagather
dagather (directed acyclic gather) is a new way to plan out and schedule asynchronous tasks. The tasks are organized, with each task specifying the tasks that come before it. The tasks are then run in topological order, ensuring that each operation will start as soon as it is able to without waiting for routines it does not need.
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
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dagather-0.0.1.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file dagather-0.0.1.tar.gz
.
File metadata
- Download URL: dagather-0.0.1.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.6 Linux/5.4.0-1031-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dec733d29becab3add85e4194e70b9d02c4e0af53501b9a34c26c63ad8a6d9d0 |
|
MD5 | 9c42f1f621e5e342c019aadf5111cf2b |
|
BLAKE2b-256 | 136ce5937b54e5fb79c10e58c51b3e0127a31f85dc15a3411aab7f9eaf648e45 |
File details
Details for the file dagather-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: dagather-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.4 CPython/3.8.6 Linux/5.4.0-1031-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0314862954e6afae0bfad94557c3841eed2a09196af3790b738ef34343702502 |
|
MD5 | 07dff2a7bb61fbcd9049bbc0796fc67d |
|
BLAKE2b-256 | 5e8cce90e43ff68a09c2b73878e69858617d7decc9981fda8ababe433f29da5c |