osiiso¶
Structured task queues for Python — one API across asyncio, threads, and processes.
What is osiiso?¶
osiiso gives you one compact queue API for three execution backends:
| Backend | Class | Best for |
|---|---|---|
| Asyncio | AsyncQueue |
HTTP clients, async databases, websockets, API fan-out |
| Threads | ThreadQueue |
Blocking I/O, synchronous SDKs, filesystem work, SQLite |
| Processes | ProcessQueue |
CPU-heavy computation, parsing, scoring, analytics |
All three queues share the same shape: submit tasks → configure options → run → inspect results.
import asyncio
import osiiso
async def fetch(name: str) -> str:
await asyncio.sleep(0.1)
return f"fetched {name}"
async def main():
async with osiiso.AsyncQueue(workers=4) as q:
q.submit(fetch, "users", priority=0)
q.submit(fetch, "posts", retries=2, retry_delay=0.25, timeout=5)
summary = await q.run(strict=True)
return summary.values
print(osiiso.run(main()))
Key Features¶
- Unified API — Same interface for async, threaded, and process queues
- Priority scheduling — Lower priority numbers execute first
- Retries with backoff — Configurable retry count, delay, and exponential backoff
- Timeouts — Per-task and queue-level time limits
- Graceful shutdown —
must_completetasks are protected during shutdown - Batch workflows —
submit(),map(), andgroup()for flexible task submission - Structured results —
RunSummaryand immutableTaskResultrecords - Lifecycle hooks —
on_start,on_complete, andon_retrycallbacks - uvloop support — Optional acceleration through
osiiso.run() - Zero dependencies — No runtime dependencies; typed with
py.typed
Quick Example¶
import asyncio
import osiiso
async def fetch(name: str) -> str:
await asyncio.sleep(0.1)
return f"fetched {name}"
async def main():
async with osiiso.AsyncQueue(workers=4) as q:
q.map(fetch, ["users", "posts", "comments"], retries=2, timeout=5)
summary = await q.run(strict=True)
print(summary.values)
osiiso.run(main())
Architecture¶
graph LR
A["submit() / map() / group()"] --> B["Priority Queue"]
B --> C["Worker Pool"]
C --> D["TaskHandle"]
D --> E["TaskResult"]
E --> F["RunSummary"]
style A fill:#6366f1,color:#fff,stroke:none
style B fill:#8b5cf6,color:#fff,stroke:none
style C fill:#a855f7,color:#fff,stroke:none
style D fill:#c084fc,color:#fff,stroke:none
style E fill:#d8b4fe,color:#1e1b4b,stroke:none
style F fill:#ede9fe,color:#1e1b4b,stroke:none
Next Steps¶
-
Get Started
Install osiiso and run your first task queue in under a minute.
-
User Guide
Learn about task submission, options, handles, groups, and lifecycle policies.
-
API Reference
Complete reference for every public class, method, and attribute.
-
Examples
See osiiso in action with the feature gallery and Hacker News pipeline.