You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 17, 2025. It is now read-only.
Depending on the availability of the contextvars module either a _ThreadLocalRuntimeContext or a _AsyncRuntimeContext is created. The former uses threading.local while the latter uses contextvars.ContextVar to store data.
gevent only supports threading.local properly. The contexts are not switched when contextvars.ContextVar is used. This results in side effects when requests are executed in parallel.
A solution to this problem is to try to detect if running under gevent and then using _ThreadLocalRuntimeContext even if contextvars are available. An implementation could be heavily inspired by this one: elastic/apm-agent-python@090b938