Hey, Sync!
This package will allow you to convert an async function or a class (that has async methods) to a sync version.
The new class name will be set as <OLD CLASS NAME>Sync
Installation
pip install heysync
Usage
Async Functions
You can convert async functions to sync function by:
- Normal usage:
from heysync import async_to_sync_func
async def async_func() -> str:
return "Hey there"
sync_func = async_to_sync_func(async_func)
# now you can call sync_func in the usual way
sync_func() # Hey there
- As a decorator:
from heysync import async_to_sync_func
@async_to_sync_func
async def some_func() -> str:
return "boo"
some_func() # boo
Classes
You can also convert async classes:
from heysync import make_sync_class
# a class with async methods
class Foo:
def __init__(self, x: int) -> None:
self.x = x
async def __aenter__(self):
self.x += 2
await async_func()
return self
async def __aexit__(self, exc_type, exc_value, exc_tb) -> None:
self.x -= 1
await async_func()
async def my_func(self) -> str:
return f"Output is {self.x}"
FooSync = make_sync_class(Foo)
with Foo(7) as foo:
foo.my_func() # Output is 9
foo.my_func() # Output is 8
Metadata
Release files for heysync 1.0.1
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 |
|---|---|---|---|---|
| heysync-1.0.1.tar.gz | 6.4 kB | Without provenance | Details for heysync-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| heysync-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for heysync-1.0.1-py3-none-any.whl |
Total release size: 13.0 kB
Release files / heysync-1.0.1.tar.gz
| Download URL | heysync-1.0.1.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bdb695f8ccc16241f598f78bf5e4aef84e9457b64cea6da736cb54ef32354754
|
|
BLAKE2b-256 checksum How to use checksums |
dc4ccd24a2d6553cff6c22f18c250fa8514a8526550cbb9a5f856c0f3b76df36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.10.9 Linux/5.15.0-1024-azure
|
Release files / heysync-1.0.1-py3-none-any.whl
| Download URL | heysync-1.0.1-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8517f03334dcc9ef0302126edad70ed75630646ed57f534cec45e8464ce4423
|
|
BLAKE2b-256 checksum How to use checksums |
1a6101b61560e1fb89089e500f1cd8023eb4f97e354cd2ae8ec51ec0ea327323
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.1 CPython/3.10.9 Linux/5.15.0-1024-azure
|
Security for heysync 1.0.1
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.