A python package for running directed acyclic graphs of asynchronous I/O operations
Likely abandoned. No release or commit for years (last release over 5 years ago).
Consider insteadonepipeline-cliPythie’s Index: 7921.5K downloads/moCompare →
pip install dagiodagio: Asynchronous I/O - with DAGs!
dagio is an embarassingly simple Python package for running directed acyclic
graphs of asynchronous I/O operations. It is built using and to be used with
Python's built-in asyncio
module, and provides a veeeery thin layer of functionality on top of it.
:sweat_smile:
- Git repository: https://github.com/brendanhasz/dagio
- Bug reports: https://github.com/brendanhasz/dagio/issues
Getting Started
Suppose you have a set of potentially long-running I/O tasks (e.g. hit a web service, query a database, read a large file from disk, etc), where some of the tasks depend on other tasks having finished. That is, you've got a directed acyclic graph (DAG) of tasks, where non-interdependent tasks can be run asynchronously.
For example, if you've got a task G which depends on E and F, but E
depends on D, and F depends on both C and D, etc:
A
|
B C
\ /|
D |
/ \|
E F
\ /
G
Coding that up using raw asyncio might look something like this:
import asyncio
class MyDag:
async def task_a(self):
# does task a stuff...
async def task_b(self):
# does task b stuff...
async def task_c(self):
# does task c stuff...
async def task_d(self):
# does task d stuff...
async def task_e(self):
# does task e stuff...
async def task_f(self):
# does task f stuff...
async def task_g(self):
# does task g stuff...
async def run():
obj = MyDag()
task_a = asyncio.create_task(obj.task_a())
task_c = asyncio.create_task(obj.task_c())
await task_a
await obj.task_b()
await task_c
await obj.task_d()
task_e = asyncio.create_task(obj.task_e())
task_f = asyncio.create_task(obj.task_f())
await task_e
await task_f
await obj.task_g()
asyncio.run(run())