An attempt at comingling async-code and nonasync-code-in-a-thread in an argonomic way.
Latest release 20241214: Initial release with @agen and @afunc decorators.
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 sychornous call anywhere in the call stack blocks the async event loop.
This module presently provides a pair of decorators for
asynchronous generators andfunctions 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.
The parameters are the same as for @agen, as this wraps the
function in an asynchronous generator which just yields the
function result.
Exceptions in the generator are reraised in the synchronous generator.
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.
Parameters:
maxsize: the size of theQueueused for communication, default1; this governs how greedy the generator may bepoll_delay: the async delay between polls of theQueueafter it was found to be empty twice in succession, default0.25sfast_poll_delay: the async delay between polls of theQueueafter it was found to be empty the first time after the start or after an item was obtained
Exceptions in the generator are reraised in the synchronous 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 20241214: Initial release with @agen and @afunc decorators.
Metadata
Release files for cs-naysync 20241214
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-20241214.tar.gz | 3.7 kB | Without provenance | Details for cs_naysync-20241214.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cs_naysync-20241214-py3-none-any.whl | Python 3 | none | any | Details for cs_naysync-20241214-py3-none-any.whl |
Total release size: 7.6 kB
Release files / cs_naysync-20241214.tar.gz
| Download URL | cs_naysync-20241214.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb87c645bb67c5cdc394bc817d3db4c0910a3217e06c8a3f2a33a19ed636dab3
|
|
BLAKE2b-256 checksum How to use checksums |
abc861df6180db4c14f0ebb8ccb0ea582a635d3a2a0ba03e9cc74f411d136cb0
|
| 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-20241214-py3-none-any.whl
| Download URL | cs_naysync-20241214-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2cd6ddbae9384a9095267dd6eb306846eae4c645de0a515a875733e0bddc08a
|
|
BLAKE2b-256 checksum How to use checksums |
3f94141f33a1fb19f6bc670d9f26eef92a72a2d49fc9063520746401f2e31b6a
|
| 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 20241214
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.