Skip to content

Use contextvars instead of thread.local to support asyncio task-local logging #248

@n1ywb

Description

@n1ywb

Python 3.7 added a new contextvars module to present a unified context-local storage API for both threaded and async programs.

https://docs.python.org/3.7/library/contextvars.html

Context managers that have state should use Context Variables instead of threading.local() to prevent their state from bleeding to other code unexpectedly, when used in concurrent code.

This seems to tie into the ongoing async logging work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions