Registry / http-networking / asyncer

asyncer

JSON →
library0.0.18pypypi✓ verified 26d ago

Asyncer is a small Python library built on top of AnyIO, focused on improving developer experience when working with `async` and `await` and mixing async with regular blocking code. It provides utility functions like `asyncify` and `syncify` to bridge asynchronous and synchronous code more conveniently, offering better editor support and type checking. It is actively maintained, with frequent minor releases.

pip install asyncer
INSTALL
IMPORT
SIG · ASYNCER
A
asyncer
http-networkingpythonv0.0.18
Install
2.0s avg
Import
251ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.0.18 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.258s · 20.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.0s · import 0.244s · 21MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

asyncify
from asyncer import asyncify
Used to call synchronous (blocking) functions from an asynchronous context without blocking the event loop.
syncify
from asyncer import syncify
Used to call asynchronous functions from a synchronous context.

This example demonstrates how to use `asyncer.asyncify` to call a regular blocking function (`blocking_function`) from within an asynchronous context (`main`). `asyncify` ensures the blocking operation runs in a worker thread, preventing it from blocking the main event loop. The `anyio.run(main)` call starts the AnyIO event loop to execute the asynchronous `main` function.

import anyio from asyncer import asyncify import time def blocking_function(name: str) -> str: """A blocking function that simulates work.""" time.sleep(0.1) # Simulate I/O or CPU-bound work return f"Hello from blocking func, {name}!" async def main(): print("Starting async main function.") # Run a blocking function in a worker thread using asyncify message = await asyncify(blocking_function)(name="World") print(message) print("Finished async main function.") if __name__ == "__main__": anyio.run(main)
Debug
Known issues
breakingAsyncer dropped support for Python 3.9 in version 0.0.15. Projects requiring Python 3.9 or older must use an earlier Asyncer version.
fix
Upgrade to Python 3.10 or higher, or pin Asyncer to `<0.0.15`.
affects: >=0.0.15
breakingAsyncer dropped support for Python 3.8 in version 0.0.12. Projects requiring Python 3.8 or older must use an earlier Asyncer version.
fix
Upgrade to Python 3.9 or higher (preferably 3.10+), or pin Asyncer to `<0.0.12`.
affects: >=0.0.12
deprecatedThe `cancellable` argument for `asyncify()` was refactored and is now `abandon_on_cancel`. Using `cancellable=True` might not have the intended effect or could lead to future breakage.
fix
Replace `asyncify(..., cancellable=True)` with `asyncify(..., abandon_on_cancel=True)`. Refer to AnyIO documentation for precise behavior of `abandon_on_cancel`.
affects: >=0.0.8
gotchaAsyncer functions, particularly `syncify`, expect to be called either from an existing asynchronous event loop (e.g., within an `async` function running via `anyio.run()` or `asyncio.run()`) or from a worker thread initiated by `asyncify`. Calling `syncify()` directly in a purely synchronous top-level context may implicitly start a new event loop or raise an error if `raise_sync_error` is not set to `False`.
fix
Ensure `asyncer` functions are used within an appropriate asynchronous context (e.g., `anyio.run()`) or explicitly handle synchronous execution with `syncify(..., raise_sync_error=False)`.
affects: All
gotchaThe Asyncer documentation recommends pinning the exact version of the library due to its small size and potential for future changes, and always having tests for your project.
fix
Pin the Asyncer version in your `requirements.txt` or `pyproject.toml` (e.g., `asyncer==0.0.17`) and maintain comprehensive tests to ensure compatibility when upgrading.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'asyncer'
The 'asyncer' library is not installed in the Python environment.
fix
Install the 'asyncer' library using pip: 'pip install asyncer'.
SyntaxError: invalid syntax
Using 'async' as an identifier conflicts with its reserved keyword status in Python.
fix
Rename the variable or module named 'async' to avoid using reserved keywords.
RuntimeWarning: coroutine 'sender' was never awaited
A coroutine was defined but not awaited, leading to it not being executed.
fix
Ensure that all coroutines are awaited using 'await' or run with an event loop.
RuntimeError: Event loop is closed
Attempting to perform an operation after the event loop has been closed.
fix
Ensure the event loop is open before performing asynchronous operations.
AttributeError: module 'asyncio' has no attribute 'StreamReader'
Attempting to access a non-existent attribute in the 'asyncio' module.
fix
Verify the correct usage and attributes of the 'asyncio' module as per the official documentation.
Upgrade
Version history
0.0.18latest on PyPI · released Jun 25, 2026
Audit
Dependencies
anyiorequiredCore asynchronous backend library that Asyncer is built upon for concurrent execution.
sniffiorequiredUsed for detecting the current asynchronous backend in use (e.g., asyncio, Trio).
typing_extensionsoptionalProvides backported typing features for older Python versions. Required for Python < 3.15.
Agent activity
21 hits · last 30 days
node
16
Amazon
1
OpenAI (training)
1
Resources
asyncer — pip install asyncer · libregistry