Layout tasks with async and flower
Project description
Async and Flower
anf allows you to elegantly organize and execute your tasks.
Installation
$ pip install anf
Example
import asyncio
from anf import run_flower
from anf import FlowerTask
async def fn_param(param: str) -> bool:
print(param)
await asyncio.sleep(2)
return True
async def main():
function_params = [
FlowerTask("p1").set_task_id("task_id-1"),
FlowerTask("p2"),
]
# run with FlowerTask list
await run_flower(function_params, fn_param, max_tasks=2)
# run with simple list
await run_flower(["p1", "p2"], fn_param, max_tasks=1)
# run with iter list
function_params = [
FlowerTask(["p1", "p2", "p3"]).set_iter(["param"]),
]
await run_flower(function_params, fn_param, max_tasks=1)
if __name__ == '__main__':
asyncio.run(main())
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
anf-1.1.0.tar.gz
(9.3 kB
view details)
File details
Details for the file anf-1.1.0.tar.gz.
File metadata
- Download URL: anf-1.1.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31ec96722609440bae625223097697461ba844ed960d4efc5f9424ba417be70e
|
|
| MD5 |
0551945f7c293ebf57c2acc5d277aa4c
|
|
| BLAKE2b-256 |
27b5bd16de5153fbe76b369f1d2e63503486f491a43f34cb6961f9ee4de81372
|