pySyncAsync
A library for template generation of synchronous and asynchronous functions in Python.
- [Release Notes](#Release Notes)
-
- [Version 0.0.1](#Version 0.0.1)
-
- [Version 1.0.0](#Version 1.0.0)
- Installation
- [Quick start](#Quick start)
- [User guide](#User guide)
-
- [Root manager](#Root manager)
-
- [Call object](#Call object)
-
- [Template function](#Template function)
- Examples
Release Notes
Version 0.0.1
Doesn't work, only library base
Version 1.0.0
- Add README
- Add Manager class
- Add root manager
- Add tests for import, common manager and root manager
Installation
You can install this library by download from GitHub:
git clone https://github.com/OlegYurchik/pySyncAsync
cd pySyncAsync
python setup.py install
or install from PyPI:
pip install pySyncAsync
Quick start
Just let me show simple code for set your templates and run them
import asyncio
import time
from random import randint
import pysyncasync as psa
@psa.register("sum")
def sync_func(a, b):
print("SUM SYNC START")
time.sleep(1)
return a + b
@psa.register("sum")
async def async_func(a, b):
print("SUM ASYNC START")
await asyncio.sleep(1)
return a + b
def worker():
a, b, c, d = (randint(0, 10**9) for _ in range(4))
call1 = psa.Call("sum", a, b)
yield call1
call2 = psa.Call("sum", c, d)
yield call2
call3 = psa.Call("sum", call1.result, call2.result)
yield call3
return call3.result
def main():
generated_worker = psa.generate(worker, psa.SYNC)
return generated_worker()
def a_main():
generated_worker = psa.generate(worker, psa.ASYNC)
loop = asyncio.get_event_loop()
return loop.run_until_complete(generated_worker())
if __name__ == "__main__":
print("SYNC SESSION")
main()
print("ASYNC SESSION")
a_main()
User guide
Manager
Root manager
Call object
Template function
Examples
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pySyncAsync-1.0.0.tar.gz
(4.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pySyncAsync-1.0.0.tar.gz.
File metadata
- Download URL: pySyncAsync-1.0.0.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50bc03146ee0b57061f7e52e95484316de2e9004ce0dc9d96364bd730a41a1dd
|
|
| MD5 |
b64419dda504c808b26f8b4c89c75a1e
|
|
| BLAKE2b-256 |
0680dc7b3579271a68076fb111b5427decac684883f2734da3bc801f2cafbef3
|
File details
Details for the file pySyncAsync-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pySyncAsync-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bff67810c0624486472f4d6fd5e783fbf4320fa6136def340a11a553c3283dd7
|
|
| MD5 |
afddc0f7ba7bae460caec8f1b760fe1f
|
|
| BLAKE2b-256 |
85d1459f03c6ef3c4a9557a3ed1abdb161abb79ae1936aef3f3537f8d7d8cab0
|