Interface for easy access to asynchrneous methods for synchroneous users
Project description
SyncAsync
This library enables you to provide your asynchronous library to synchronous users, while still enabling you, to use it as intended.
Installation
pip install sync-async
Hello World
from SyncAsync import SyncAsync
class Example(SyncAsync):
@SyncAsync.sync
async def hello_world(self, txt: str):
print(txt)
def main(api: Example):
api.hello_world("Hello World")
async def aio_main(api: Example):
await api.hello_world("Hello Sky")
if __name__ == "__main__":
example = Example()
main(example) # Prints 'Hello World'
import asyncio
asyncio.get_event_loop().run_until_complete(aio_main(example)) # Prints 'Hello Sky'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sync_async_api-0.1.0.tar.gz
(2.8 kB
view hashes)
Built Distribution
Close
Hashes for sync_async_api-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36535c36f386edea24bb090e5158cc2cb02529b81971b3ca186f73f017a74e87 |
|
MD5 | eecefb034151519bddb19f53518a236a |
|
BLAKE2b-256 | ba1fa5e3e1fe6bf0ee5ce01c5bc552c967dfeb78e618a9743f68db78a22da3ed |