Skip to content

exiting with push_scope() fails if new client is bound #159

Description

@FelixLC

Similarly to #147, we started to get popped wrong scope assertion errors in a Falcon app sending jobs to redis-queue after updating to sentry-sdk from raven

Our Python 3.5.2 stack:

rq==0.12.0
redis==2.10.6
sentry-sdk==0.5.2

The worker is initialized like this:

    listen = [l.value for l in constants.QueueList]
    conn = redis.from_url(os.environ.get(
        'REDIS_WORKER', 'redis://redis_worker:6379'))

    sentry_sdk.init(sentry_key,
                    environment=environment,
                    release=release,
                    integrations=[RqIntegration()])
    with Connection(conn):
        worker = Worker(list(map(Queue, listen)))
        worker.work(logging_level='WARNING')

If it's the same kind of issue, would a change from:

            with hub.push_scope() as scope:
                scope.add_event_processor(_make_event_processor(weakref.ref(job)))
                rv = old_perform_job(self, job, *args, **kwargs)

to

            with Hub(hub) as hub:
                with hub.configure_scope() as scope:
                    scope.add_event_processor(_make_event_processor(weakref.ref(job)))
                    rv = old_perform_job(self, job, *args, **kwargs)

in https://github.com/getsentry/sentry-python/blob/master/sentry_sdk/integrations/rq.py#L28 do the job ?

If not, I'd be happy to provide more info

Metadata

Metadata

Assignees

Labels

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions