Registry / http-networking / unsync

unsync

JSON →
library1.4.0pypypi✓ verified 84d ago

unsync is a decorator-based library that bridges synchronous and asynchronous Python code. It allows you to call async functions from sync code and vice versa without manually managing event loops. Current version is 1.4.0. Release cadence is low; last release was in 2020.

pip install unsync
INSTALL
IMPORT
SIG · UNSYNC
U
unsync
http-networkingpythonv1.4.0
Install
2.4s avg
Import
213ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.4.0 · 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.226s · 19.2MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.4s · import 0.200s · 20MB
17MB installed
● package 17MB
Code
Verified usage

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

unsync
from unsync import unsync
import unsync
Importing the module directly without the decorator name will not give you the decorator function.
UnsupportedError
from unsync import UnsupportedError
Exception raised for unsupported operations.

Decorate an async function with @unsync to call it from synchronous code; the decorated function returns a concurrent.futures.Future or similar object.

from unsync import unsync import asyncio @unsync async def async_function(): await asyncio.sleep(0.1) return "Hello from async" result = async_function() print(result)
Debug
Known issues
gotchaUsing @unsync in an async context (e.g., inside another async function) may cause unexpected behavior; prefer direct await.
fix
Use await directly when already in an async function instead of @unsync.
affects: all
gotchaThe unsync decorator returns a future-like object, not the immediate result; you must call .result() or iterate accordingly.
fix
Call .result() on the returned object to get the value (e.g., async_function().result()).
affects: all
gotchaGlobal event loops can cause issues if multiple event loops are created, especially in test suites.
fix
Use asyncio.run() for top-level async calls instead of relying on unsync's loop management.
affects: all
Errors
Common errors & fixes
RuntimeError: There is no current event loop in thread 'MainThread'.
Calling an unsync-decorated function from a context where no event loop is running.
fix
Ensure there is a running event loop, or use asyncio.run() or unsync's own setup if in a synchronous context.
AttributeError: module 'unsync' has no attribute 'unsync'
Importing unsync with 'import unsync' instead of 'from unsync import unsync'.
fix
Use 'from unsync import unsync' to import the decorator.
Upgrade
Version history
1.4.0latest on PyPI · released Oct 21, 2021
Audit
Dependencies

No dependency data recorded yet.

Agent activity
52 hits · last 30 days
node
46
OpenAI (training)
2
Resources
unsync — pip install unsync · libregistry