unblock
unblock provides small utilities that convert synchronous functions, methods, and classes into asynchronous ones for use inside an asyncio event loop. It offloads blocking work to a thread or process pool so it does not block the loop.
For full documentation, see https://unblock.readthedocs.io/en/latest/
Install (distribution name is get-unblock, import name is unblock):
pip install get-unblock
Quick example:
import asyncio
from unblock import asyncify
@asyncify
def my_sync_func():
... # do something blocking
if __name__ == "__main__":
asyncio.run(my_sync_func())
Run on a process pool instead of threads:
@asyncify(executor="process")
def cpu_bound(n):
return sum(i * i for i in range(n))
Development
Requires Python 3.10+.
python -m venv .venv
. .venv/Scripts/activate # or: source .venv/bin/activate
pip install -e ".[dev]"
ruff check .
ruff format --check .
mypy
pytest --cov=unblock --cov-branch
Release Notes
0.1.0
A ground-up refactor of the library. There is no compatibility with 0.0.1.
- One unified
asyncifyentry point for functions, methods, and classes, with anexecutorparameter ("thread","process", or anExecutorinstance).@asyncify(executor="process")now works as a decorator on importable functions. - A single executor-configurable mixin family (
AsyncMixin,AsyncIterMixin,AsyncContextMixin,AsyncContextIterMixin) replaces the previous eight base classes; method names no longer need to be listed as strings. async_propertyandasync_cached_propertyredesigned as proper descriptors; the cached variant now computes exactly once even under concurrent awaits.- Work always binds to the running event loop (fixes cross-loop errors); the return-type duality (started future when a loop runs, coroutine otherwise) is documented.
- Thread/process pools are bounded, created thread-safely, and shut down cleanly
via
shutdown()and anatexithook. - Asynchronous tasks still start in the background when a loop is running; you
awaitonly to collect the result. - Works with asyncio-compatible event loops (asyncio, uvloop). It does not support trio/curio, which are not asyncio compatible natively.
- Ships type information (PEP 561). Supports Python 3.10 and above.
Metadata
Release files for get-unblock 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| get_unblock-0.1.1.tar.gz | 134.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| get_unblock-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 154.0 kB
Release files / get_unblock-0.1.1.tar.gz
| Download URL | get_unblock-0.1.1.tar.gz |
|---|---|
| Size | 134.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa3d00cfa9724c44e6098ab3203c43d9ba9d0a0b47f0bab4cea91fef677d0dd0
|
|
BLAKE2b-256 checksum How to use checksums |
00642b26023a61d5c43b7a2aafe9bc955a1029f3e9016f518cb8f3e65bcbd2c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.
Transparency logRelease files / get_unblock-0.1.1-py3-none-any.whl
| Download URL | get_unblock-0.1.1-py3-none-any.whl |
|---|---|
| Size | 19.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4797eb032c822beff32c8107ac201e2351fee6c4bdb851bd5be09a53c1e2aee0
|
|
BLAKE2b-256 checksum How to use checksums |
91367cd4265e9a7eef50361cf1a9df1eca7dadad39a5e36682368d42ca8c0ad2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.
Transparency log