This package is based on https://github.com/django/asgiref/blob/master/asgiref/sync.py
Sync-to-async and async-to-sync function wrappers
These allow you to wrap or decorate async or sync functions to call them from the other style (so you can call async functions from a synchronous thread, or vice-versa).
In particular:
AsyncToSync lets a synchronous subthread stop and wait while the async function is called on the main thread’s event loop, and then control is returned to the thread when the async function is finished.
SyncToAsync lets async code call a synchronous function, which is run in a threadpool and control returned to the async coroutine when the synchronous function completes.
The idea is to make it easier to call synchronous APIs from async code and asynchronous APIs from synchronous code so it’s easier to transition code from one style to the other. In the case of Channels, we wrap the (synchronous) Django view system with SyncToAsync to allow it to run inside the (asynchronous) ASGI server.
Dependencies
syncasync requires Python 3.5 or higher.
Test
To run tests, make sure you have installed the tests extra with the package:
pip install -e .[tests] pytest
Release files for syncasync 20180812
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| syncasync-20180812.tar.gz | 3.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| syncasync-20180812-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 6.5 kB
Release files / syncasync-20180812.tar.gz
| Download URL | syncasync-20180812.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
737cd0193b5e0659b1565122069b5178001210f221f4641eca0d94c58c8eb4d2
|
|
BLAKE2b-256 checksum How to use checksums |
c676b65cc583347fd16a9a01f967a325d119a0a73b7a3487364d80b7dc8c9be2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5
|
Release files / syncasync-20180812-py2.py3-none-any.whl
| Download URL | syncasync-20180812-py2.py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f581db7f968b88c8eea83b06341025a4588bbbcecc83345956a85f0ae9777729
|
|
BLAKE2b-256 checksum How to use checksums |
0d0b8ad1a350eebbee61558422e678553d192ec2b96d57ba633a0acce16b81ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5
|