Learn Python with Talk Python's 270 hours of courses

18 awesome asyncio packages in Python

Episode #389, published Wed, Nov 9, 2022, recorded Thu, Nov 3, 2022

If you're a fan of Python's async and await keywords and the powers they unlock, then this episode is for you. We have Timo Furrer here to share a whole bunch of asyncio related Python packages. Timo runs the awesome-asyncio list and he and I picked out some of our favorites to share with you.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guest Introduction and Background

Timo Furrer is the guest on this episode. He’s a seasoned Python developer who curated the popular awesome-asyncio list on GitHub, which highlights top-notch AsyncIO libraries. Timo has experience working at companies like Roche, managing hardware simulation frameworks in Python, and he currently works as a Senior Backend Engineer at GitLab. His passion lies in exploring Python’s async world and sharing these discoveries with the developer community.

What to Know If You're New to Python

If you’re just getting started with Python, you’ll need some foundational knowledge to follow the many libraries and concepts covered here. Here are a few helpful points:

  • Understand the basics of Python functions, imports, and package installation (via pip or conda).
  • Know what “async” and “await” mean in Python: they let you handle networking and other I/O tasks without blocking.
  • Be aware that async code generally helps with concurrency and is not usually about raw parallel CPU work.

Key Points and Takeaways

  1. The Power of AsyncIO and Its Ecosystem AsyncIO allows Python developers to handle high-latency or external I/O tasks more efficiently by using async and await. This episode focuses on numerous libraries and packages that build on AsyncIO for tasks like networking, web development, database interaction, and more.
  2. Notable Async Web Frameworks FastAPI, Starlette, Quart, and Sanic are among the frameworks built from the ground up for async. These micro- to full-stack frameworks showcase how AsyncIO can handle web requests and background tasks in a highly performant and Pythonic way.
  3. Async Database Drivers and ORMs Async drivers like asyncpg (for PostgreSQL) and motor (for MongoDB) improve performance by never blocking the main event loop. Libraries such as Piccolo ORM and others showcase how ORM queries can also be written in Pythonic, async-friendly syntax to simplify database operations.
  4. Testing Async Code Tools like pytest-asyncio make it straightforward to write async tests by allowing async test functions. This ensures code that relies on awaitable calls can be validated without complex manual event-loop management.
  5. Accelerating Async with UVloop UVloop offers a drop-in replacement for Python’s built-in event loop, promising 2x-4x speed improvements. Many async web servers (like Uvicorn) will automatically use UVloop if it’s installed, making it nearly effortless to boost performance.
  6. Caching and File Handling Libraries Libraries like AIO Cache let developers easily cache results with async syntax, supporting backends like Redis or Memcached. Additionally, AIO Files and AIO Path facilitate asynchronous file operations, often by pushing file I/O into background threads or using OS-level async hooks.
  7. Communicating Across Coroutines (Channels and Queues) Packages like iochan bring Go-style channels to Python’s async ecosystem. By combining channels or queues with producers and consumers, it’s easier to coordinate tasks in more advanced concurrency scenarios.
  8. Alternate Approaches: Trio, Curio, and AnyIO Trio and Curio are alternative async libraries that try to simplify concurrency or experiment with different concurrency models. AnyIO can wrap either Trio or AsyncIO, bridging both worlds and providing advanced concurrency APIs like parallel subprocess handling.
  9. Retries and Resilience with Tenacity For handling unpredictable or flaky external services, the Tenacity library provides decorators for both sync and async retry logic. It’s a clean, flexible way to implement exponential backoff, timeouts, and dynamic retry conditions.
  10. Using “Awesome Lists” as a Community Resource Timo’s awesome-asyncio is part of a broader “awesome” category on GitHub, where contributors curate the best tools in a niche. The Python async community is active, so these lists offer a jumping-off point to find well-maintained, popular, or inventive libraries for your projects.

Interesting Quotes and Stories

  • Timo on discovering new packages: “It’s nice to just browse through once in a while and see where the ecosystem is at and what new things have been popping up.”
  • On performance benchmarks: “In the real world, it’s often your business logic that is slowing you down, not the web framework itself.”
  • On adopting AsyncIO: “AsyncIO unlocks concurrency in Python without having to drastically rethink how your code is written.”

Key Definitions and Terms

  • AsyncIO: A Python library introduced in Python 3.4+ for writing concurrent code using the async/await syntax.
  • Channels: Concurrency primitives (inspired by Go) that allow coroutines to communicate by sending values through channel endpoints.
  • ORM (Object Relational Mapper): A layer that allows developers to interact with a database using Python objects and methods instead of direct SQL.
  • Event Loop: The core of async applications, repeatedly looking for I/O events, scheduling tasks, and handling coroutine execution.

Learning Resources

If you want to strengthen your Python foundation or become more comfortable with async concepts, you can explore these courses:

Overall Takeaway

AsyncIO is a powerful part of modern Python, and this episode showcases a rich ecosystem of libraries that can boost performance and productivity. From web frameworks and database drivers to testing tools and concurrency primitives, the async landscape is evolving quickly—making Python more capable than ever for high-concurrency applications.

Links from the show

Timo on Twitter: @tuxtimo
awesome-asyncio list: github.com

Some of the highlighted packages
FastAPI: github.com
starlette: github.com
sanic: github.com
uvicorn - The lightning-fast ASGI server: github.com
Tech Empower Python Framework benchmarks: techempower.com
aioamqp - AMQP implementation using asyncio: github.com
pyzmq - Python bindings for ZeroMQ: github.com
Scaling Python and Jupyter with ZeroMQ Talk Python episode: talkpython.fm/306
asyncpg - Fast PostgreSQL Database Client: github.com
Piccolo - An ORM / query builder: github.com
aiosqlite: github.com
motor - The async Python driver for MongoDB: github.com
AsyncSSH: github.com
HTTPX: github.com
pytest-asyncio - Pytest support for asyncio: github.com
uvloop - Ultra fast implementation of asyncio event loop: github.com
aiocache - Cache manager for different backends: github.com
aiofiles - File support for asyncio: github.com
aiopath - Asynchronous pathlib for asyncio: github.com
Video: Demystifying Python's Async and Await Keywords - JetBrains TV 2020 (Michael Kennedy): youtube.com
tenacity: readthedocs.io
Michael's full 5 hour async course: talkpython.fm/async
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm

--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy

Talk Python's Mastodon Michael Kennedy's Mastodon