Skip to content

ValueError: <Token var=<ContextVar name='current_scope' default=None at 0xXXX> at 0xYYY> was created in a different Context #3724

Open

Description

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.12.0

Steps to Reproduce

Noticed the following error in the asyncio integration. It crashes the program. I have the following init:

        sentry_sdk.init(
            dsn=settings.sentry_dsn,
            environment=settings.env,
            integrations=[
                AsyncioIntegration(),
                LoguruIntegration(),
                FastApiIntegration(),
                OpenAIIntegration(),
                RedisIntegration(),
                HttpxIntegration(),
                AioHttpIntegration(),
            ],
            traces_sample_rate=1.0,
            profiles_sample_rate=1.0,
        )

Can it be somehow related to #2908?

Expected Result

No crash.

Actual Result

Traceback (most recent call last):
  File "/venv/lib/python3.11/site-packages/sentry_sdk/integrations/asyncio.py", line 46, in _coro_creating_hub_and_span
    with sentry_sdk.isolation_scope():
  File "/venv/lib/python3.11/site-packages/sentry_sdk/scope.py", line 1628, in isolation_scope
    _current_scope.reset(current_token)
  File "/usr/local/lib/python3.11/contextlib.py", line 158, in __exit__
    self.gen.throw(typ, value, traceback)
ValueError: <Token var=<ContextVar name='current_scope' default=None at 0x7cc13c5a72e0> at 0x7cc0dc4eb880> was created in a different Context

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Waiting for: Community

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions