Async Services
Run fast asynchronous code from a synchronous code. Async Services provide a synchronous wrapper to run third party asynchronous code or any coroutine for that matter in a synchronous way from a synchronous code.
Installation
pip install async_services
For Development Purposes
Install project Dependencies
pip install -r requirements.txt
pip install -U .
Running the tests
You can run the tests with the following command
pytest .
And coding style tests
pycodestyle .
Example Usage
from async_services.core import run_coro, run_manager, stop_manager
from async_services.core.manager import CoroStatus
import asyncio
async def coroutine(seconds=1, raise_exception=False):
await asyncio.sleep(seconds)
if raise_exception:
raise Exception("Sample Exception")
return "Hello World"
run_manager()
result = run_coro(coroutine(), block=True)
print(result)
assert result[0] == CoroStatus.Completed
assert result[1] == "Hello World"
stop_manager()
Output
Result will be a tuple consisting of two values (status, result) status will be a integer between 0 and 5 and it defines the state of the coruotine
(1, 'Hello World')
Coroutine Status
Presently there are six status of a coruotine
- Queued = 0 -> Coroutine is still queued waiting to be executed or is being executed
- Completed = 1 -> Coroutine has Completed Successfully
- Failed = 2 -> Coroutine Completed Successfully , But callback function raised an exception
- Cancelled = 3 -> Coroutine was Cancelled
- Timeout = 4 -> Coroutine did not complete in the given time
- CoroutineException = 5 -> Coroutine Itself Raised an Exception
Authors
- Ankit Kathuria - Initial work
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgments
- Hat tip to anyone whose code was used
- Inspiration
- etc
Metadata
Release files for async-services 1.0.2
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 |
|---|---|---|---|---|
| async_services-1.0.2.tar.gz | 5.2 kB | Without provenance | Details for async_services-1.0.2.tar.gz |
Release files / async_services-1.0.2.tar.gz
| Download URL | async_services-1.0.2.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
63e9aba894cc81365441fe739eca5654e36874a0585dbcba2a088c9a48e7e1ab
|
|
BLAKE2b-256 checksum How to use checksums |
78c81640d203fb77efede6c5ce0cee002b0c8214e80cc5722a2dcc3ef55b947d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.7
|
Security for async-services 1.0.2
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.