Simple concurrent runner for async tasks, threads and processes – one API, one object.
conrunis under active development. Untilv1.0the public API may change without notice. Feel free to experiment, but pin the exact version in production.
- One-liner concurrency – run any coroutine, function, or CPU-bound task concurrently with a single call.
- Three modes
•
async→ nativeasyncioconcurrency •thread→ThreadPoolExecutorunder the hood •process→ProcessPoolExecutorfor CPU-bound work - Safe nesting – a single
Runnercan be reused recursively; the executor shuts down exactly once. - Back-pressure –
max_workers+ semaphore keep concurrency under control. - Sync and async entry points – call from “normal” code (
run) or inside an event loop (arun).
Supported Python versions: 3.10 · 3.11 · 3.12 · 3.13
pip install conrunimport asyncio
from conrun import Runner
async def my_function(text: str) -> str:
await asyncio.sleep(1)
return text.upper()
async def main():
result = await Runner(mode="async", max_workers=3).arun(
my_function,
["a", "b", "c"],
)
print(result) # ['A', 'B', 'C']
if __name__ == "__main__":
asyncio.run(main())MIT