Skip to main content

contextvars_executor

info:

contextvars friendly ThreadPoolExecutor

https://travis-ci.org/hellysmile/contextvars_executor.svg?branch=master https://img.shields.io/pypi/v/contextvars_executor.svg https://codecov.io/gh/hellysmile/contextvars_executor/branch/master/graph/badge.svg

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)

Source distribution for contextvars-executor 0.0.1
File Size Uploaded Provenance Actions
contextvars_executor-0.0.1.tar.gz 2.2 kB Without provenance Details for contextvars_executor-0.0.1.tar.gz

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+

Security for contextvars-executor 0.0.1

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.

Release history Release notifications | RSS feed

This release

0.0.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page