Automation · Python Automation
AsyncIO
Cheat sheet · https://pcornel.dk/topic.php?topic=5273
Answer
AsyncIO is Python's library for asynchronous code with async and await, letting one thread handle many concurrent network operations, such as polling hundreds of devices with aiohttp or asyncssh.
Remember
- async/await in one thread.
- aiohttp, asyncssh.
- Limit with semaphores.
First checks
python3 -c 'import asyncio;print(asyncio.run(asyncio.sleep(0,"ok")))'— asyncio works- Semaphore for concurrency limit — protection
- Timeouts with asyncio.wait_for — hangs
Verify in this order
tasks → event loop → concurrent I/O → results
Where it usually breaks
Commit/input → runner/job → build/test artifact → deployment request → target rollout/reconcile → effective version/config → health/readiness → workload.
Python Automation → AsyncIO · operational reference
| Layer | Python Automation → AsyncIO operational reference |
|---|---|
| Runtime/ownership | Python asyncio event loop and structured asynchronous I/O · identify controller/parser, durable intent, identity and target ownership before mutation |
| Persistent intent | Versioned definition/configuration with explicit dependencies, scope and credential boundary |
| Verification | python -X dev async_probe.py; capture task names/results/exceptions, timeout/cancellation paths and resource cleanup. |
| Expected interpretation | Coroutines execute on the intended event loop, awaited tasks finish or cancel deterministically, exceptions are observed, blocking work does not stall the loop, and resources close cleanly. |
| Recovery boundary | Preserve correlation IDs + pre-state, repair first failing boundary, then verify the target independently |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5273