#asyncio
4 posts tagged asyncio. All posts
Handling LLM API rate limits: retries, backoff and concurrency capsTell 429s from 529s and 5xx errors, use the Anthropic SDK's built-in retries, add backoff with jitter, and cap concurrency and input tokens with asyncio.
contextlib patterns in Python: contextmanager, ExitStack, suppress and chdirWrite context managers with @contextmanager, handle exceptions in them, manage many resources with ExitStack, and use suppress, chdir and async versions.
A small eval runner for LLM features in PythonBuild a 160-line eval runner for an LLM feature: JSONL test cases, exact, regex and LLM-as-judge graders, concurrent runs and scores tracked per prompt version.
asyncio TaskGroup and asyncio.timeout: structured concurrency in PythonReplace asyncio.gather with TaskGroup, handle failures with ExceptionGroup and except*, add deadlines with asyncio.timeout, and cap concurrency.
© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)