Desync
Simple conversions between synchronous and asynchronous functions and function
calls. You can use it to wait (really block) for asynchronous function results
with sync or create synchronous versions with synced:
# Assume async_func is asynchronous.
async_func: Callable[..., Awaitable[T]]
# Call async_func and wait for its result synchronously:
result: T = sync(async_func, *args, **kwargs)
# Create a version which is synchronous without calling it:
desynced_func: Callable[..., T] = synced(async_func)
You can also wait for synchronous functions via desync or create asynchronous
versions with desynced:
# Assume sync_func is synchronous.
func: Callable[..., T]
# Call sync_func and wait for its result in an asynchronous context:
awaitable: Awaitable[T] = desync(sync_func, *args, **kwargs)
result: T = await awaitable
# Create a version which is asynchronous without calling it:
descyned_func: Callable[..., Awaitable[T]] = desynced(func)
Desynced functions run in parallel (as far as python can run in parallel).
def wait_some():
time.sleep(1)
return 1
# This should take approx. 1 second:
assert 10 == sum(
await asyncio.gather(*(
desync(wait_some) for i in range(10)
))
)
Release files for pydesync 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pydesync-0.1.3.tar.gz | 7.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydesync-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.4 kB
Release files / pydesync-0.1.3.tar.gz
| Download URL | pydesync-0.1.3.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e78b4e4d146a123b224bba5562d4fbc1d749eea5b0ad4764ab8f39d2b1bc23c
|
|
BLAKE2b-256 checksum How to use checksums |
4396fa4e7d3f63bc018c03e8da6ed425c87c6b945f0e909b4c02ab8f428eddc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.12
|
Release files / pydesync-0.1.3-py3-none-any.whl
| Download URL | pydesync-0.1.3-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e2a43e28aba73a9c6b96a96157a884d7b05c26c256a660ac3e247db5af98e5c
|
|
BLAKE2b-256 checksum How to use checksums |
11b6fe352e3165ba95dde68bef06465275622afba7ef7d407cd2ec3e948d56ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.12
|