- info:
contextvars friendly ThreadPoolExecutor
Installation
pip install contextvars_executor
Why???
Usage
import asyncio
import contextvars
from contextvars_executor import ContextVarExecutor
ctx = contextvars.ContextVar('42')
def thread():
ret = ctx.get()
assert ret == 42
return ret
async def main(*, loop):
ctx.set(42)
ret = await loop.run_in_executor(None, thread)
assert ret == 42
loop = asyncio.get_event_loop()
loop.set_default_executor(ContextVarExecutor())
loop.run_until_complete(main(loop=loop))
Python 3.7+ is required, there is no need to support older python versions!!!
Metadata
Release files for contextvars-executor 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| contextvars_executor-0.0.1.tar.gz | 2.2 kB | Details |
Release files / contextvars_executor-0.0.1.tar.gz
| Download URL | contextvars_executor-0.0.1.tar.gz |
|---|---|
| Size | 2.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a47c1e8c29cbdb9006dae5d03be7fd329b5585fe8f0b62e0cd94eaf4db741bd
|
|
BLAKE2b-256 checksum How to use checksums |
2ab7b465571636dfd2ae00f26a8647183e9d97ea2daca790347db5c27a4ec423
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.2 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.7.0a4+
|