An attempt at comingling async-code and nonasync-code-in-a-thread in an argonomic way.
Latest release 20241215:
- @afunc: now uses asyncio.to_thread() instead of wrapping @agen, drop the decorator parameters since no queue or polling are now used.
- @agen: nonpolling implementation - now uses asyncio.to_thread() for the next(genfunc) step, drop the decorator parameters since no queue or polling are now used.
One of the difficulties in adapting non-async code for use in an async world is that anything asynchronous needs to be turtles all the way down: a single blocking synchronous call anywhere in the call stack blocks the async event loop.
This module presently provides a pair of decorators for
asynchronous generators and functions which dispatches them in
a Thread and presents an async wrapper.
afunc(*da, **dkw)
A decorator for a synchronous function which turns it into an asynchronous function.
Example:
@afunc
def func(count):
time.sleep(count)
return count
slept = await func(5)
agen(*da, **dkw)
A decorator for a synchronous generator which turns it into an asynchronous generator. Exceptions in the synchronous generator are reraised in the asynchronous generator.
Example:
@agen
def gen(count):
for i in range(count):
yield i
time.sleep(1.0)
async for item in gen(5):
print(item)
Release Log
Release 20241215:
- @afunc: now uses asyncio.to_thread() instead of wrapping @agen, drop the decorator parameters since no queue or polling are now used.
- @agen: nonpolling implementation - now uses asyncio.to_thread() for the next(genfunc) step, drop the decorator parameters since no queue or polling are now used.
Release 20241214.1: Doc update.
Release 20241214: Initial release with @agen and @afunc decorators.
Metadata
Release files for cs-naysync 20241215
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cs_naysync-20241215.tar.gz | 3.2 kB | Without provenance | Details for cs_naysync-20241215.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cs_naysync-20241215-py3-none-any.whl | Python 3 | none | any | Details for cs_naysync-20241215-py3-none-any.whl |
Total release size: 6.5 kB
Release files / cs_naysync-20241215.tar.gz
| Download URL | cs_naysync-20241215.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
504eaa65014af23d048e6657c5e0c59478ea71ae4f90a09de39e1ee4029ff7f8
|
|
BLAKE2b-256 checksum How to use checksums |
1e4ddcfa64f62b6dbd5911fa9772a260966e20bdb4f97da3119c4cd5515ba1e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.7
|
Release files / cs_naysync-20241215-py3-none-any.whl
| Download URL | cs_naysync-20241215-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58d6fe83134445ad9a91cf26d52b8cbe1fb374b2b586a4e8783d5d09b2dfa740
|
|
BLAKE2b-256 checksum How to use checksums |
cd38205d5ef71bb9354a2ef9271f484aebaf2121c68e1fee79053b9ed36b7fd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.7
|
Security for cs-naysync 20241215
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.