Skip to main content

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 asyncify entry point for functions, methods, and classes, with an executor parameter ("thread", "process", or an Executor instance). @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_property and async_cached_property redesigned 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 an atexit hook.
  • Asynchronous tasks still start in the background when a loop is running; you await only 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)

Source distribution for get-unblock 0.1.1
File Size Uploaded
get_unblock-0.1.1.tar.gz 134.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for get-unblock 0.1.1
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page