Skip to content

Python contextvars don't persist across cells in notebook #11565

@saulshanabrook

Description

@saulshanabrook

Python 3.7 added a new contextvars package to "manage, store, and access context-local state".

However, if I set a ContextVar in one cell and then try to get it in another, it isn't persisted:

This may be an antipattern (not sure if there is a good use case to set a variable across many cells) and I worked around it by setting default, as recommended. However it is surprising and is different than how ipython works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions