Run an asyncio loop in it's own thread for scheduling awaitables from within Pyramid views.
This adds request property loop and request methods wait_for,
wait_results, and await.
The loop property returns the loop running
in it's own thread. Use this loop with asyncio.run_coroutine_threadsafe
to run awaitables. For example:
import asyncio
from concurrent import futures
def my_view(request):
running = asyncio.run_coroutine_threadsafe(my_coroutine(), request.loop)
done, not_done = futures.wait([running, ...], timeout=3)
results = [ftr.result() for ftr in done]
return {'done': results}
The wait_for method reduces the above boiler plate by waiting for the
futures. Example usage
def my_view(request):
done, not_done = request.wait_for([my_coroutine(), ...])
results = [ftr.result() for ftr in done]
return {'done': results}
The wait_results method reduces the boiler plate further by returning
the results after waiting. This is useful if you don't care about
unfinished tasks. Example usage:
def my_view(request):
results = request.wait_results([my_coroutine(), ...])
return {'done': results}
The await method runs a single awaitable and
blocks until it's results are complete or timeout passes.
Example usage:
from frond import AwaitableTimeout
def my_view(request):
try:
result = request.await(my_coroutine(), timeout=3)
except AwaitableTimeout:
result = 'not completed'
return {'result': result}
Use as any other Pyramid plugin:
config.include('frond')
Currently this package only supports Python 3 (and only tested on Python >=3.6).
Metadata
Release files for frond 0.0.4
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 | |
|---|---|---|---|---|
| frond-0.0.4.tar.gz | 2.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| frond-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.3 kB
Release files / frond-0.0.4.tar.gz
| Download URL | frond-0.0.4.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6fa29333f6b4c3f0328909ed61b2865de195267bfbbcd21edc800318be07c2ad
|
|
BLAKE2b-256 checksum How to use checksums |
f2c847ac7ef27af8b74e8e0b26645458bd6b6d8c094f3709c86b61e0d55be131
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / frond-0.0.4-py3-none-any.whl
| Download URL | frond-0.0.4-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
532c573323db9d2960cc175d7e1a9406d29877623f1eff4eb2b5f36f6f532b73
|
|
BLAKE2b-256 checksum How to use checksums |
26738ade4da3f9d937195fe886ec4908b9f7c0f30981e705dd401b427e0a75c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for frond 0.0.4
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.