async def _run_app(self, scope, callback):
    if _asgi_middleware_applied.get(False):
        return (await callback())
    _asgi_middleware_applied.set(True)
    try:
        hub = Hub(Hub.current)
        with hub:
            with hub.configure_scope() as sentry_scope:
                sentry_scope.clear_breadcrumbs()
                sentry_scope._name = 'asgi'
                processor = partial(self.event_processor, asgi_scope=scope)
                sentry_scope.add_event_processor(processor)
            ty = scope['type']
            if (ty in ('http', 'websocket')):
                transaction = Transaction.continue_from_headers(dict(scope['headers']), op='{}.server'.format(ty))
            else:
                transaction = Transaction(op='asgi.server')
            transaction.name = _DEFAULT_TRANSACTION_NAME
            transaction.set_tag('asgi.type', ty)
            with hub.start_transaction(transaction):
                try:
                    return (await callback())
                except Exception as exc:
                    _capture_exception(hub, exc)
                    raise exc from None
    finally:
        _asgi_middleware_applied.set(False)
async def _run_app(self, scope, callback):
    if _asgi_middleware_applied.get(False):
        return (await callback())
    _asgi_middleware_applied.set(True)
    try:
        hub = Hub(Hub.current)
        with hub:
            with hub.configure_scope() as sentry_scope:
                sentry_scope.clear_breadcrumbs()
                sentry_scope._name = 'asgi'
                processor = partial(self.event_processor, asgi_scope=scope)
                sentry_scope.add_event_processor(processor)
            ty = scope['type']
            if (ty in ('http', 'websocket')):
                transaction = Transaction.continue_from_headers(dict(scope['headers']), op='{}.server'.format(ty))
            else:
                transaction = Transaction(op='asgi.server')
            transaction.name = _DEFAULT_TRANSACTION_NAME
            transaction.set_tag('asgi.type', ty)
            with hub.start_transaction(transaction):
                try:
                    return (await callback())
                except Exception as exc:
                    _capture_exception(hub, exc)
                    raise exc from None
    finally:
        _asgi_middleware_applied.set(False)