Skip to content

IPykernel >= 7.0.0 ContextVar values are not preserved between cells #1457

Closed

Description

@RRRajput

If a value is assigned to a contextvar, it will not be preserved when moving to another cell in the notebook.
See this short example:

# cell 1
from contextvars import ContextVar

bro = ContextVar("bro", default="thisismydefaultvalue")
bro.get()
>> 'thisismydefaultvalue'
# cell 2
bro.set("!!!!!!!!!!!MODIFIED!!!!!!!")
bro.get()
>> '!!!!!!!!!!!MODIFIED!!!!!!!'
# cell 3
bro.get()
>> 'thisismydefaultvalue'

I've verified that this issue does not occur for ipykernel<7.0.0

Activity

  1. minrk commented on Oct 20, 2025

    @minrk
    Member

    SHould be fixed by #1462

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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