Skip to content

aclose() exception in Uvicorn when subscription running #172

@kdowney-cloudwallcapital

Description

After less than 30 seconds of subscribing the Tartiflette ASGI implementation blows up with an exception.

I see this both with Altair and with a simple Python graphql_client-based client, so pretty sure this is Tartiflette not the client. The platform is Ubuntu focal, Python 3.8.12, with:

  • tartiflette==1.4.1
  • tartiflette-asgi==0.11.0
  • uvicorn==0.15.0
  • websockets==9.1

Note same issue also observed with uvicorn 0.17.0-post1 and websockets 10.1, though the error recovery appears a bit more graceful with the newer versions.

This is quite critical for us as our backend is all based on Tartiflette, and I cannot switch to another GraphQL server implementation due to core library conflicts with another major library in our stack.

2022-01-26 20:48:51,050 [Thread-7] - uvicorn.error - ERROR - Exception in ASGI application
Traceback (most recent call last):
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/uvicorn/protocols/websockets/websockets_impl.py", line 203, in run_asgi
    result = await self.app(self.scope, self.asgi_receive, self.asgi_send)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 146, in __call__
    await self.app(scope, receive, send)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/starlette_exporter/middleware.py", line 101, in __call__
    await self.app(scope, receive, send)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/starlette/exceptions.py", line 58, in __call__
    await self.app(scope, receive, send)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/starlette/routing.py", line 656, in __call__
    await route.handle(scope, receive, send)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/starlette/routing.py", line 408, in handle
    await self.app(scope, receive, send)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/tartiflette_asgi/_app.py", line 90, in __call__
    await self.app(scope, receive, send)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/tartiflette_asgi/_middleware.py", line 14, in __call__
    await self.app(scope, receive, send)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/starlette/routing.py", line 656, in __call__
    await route.handle(scope, receive, send)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/starlette/routing.py", line 315, in handle
    await self.app(scope, receive, send)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/starlette/endpoints.py", line 76, in dispatch
    await self.on_disconnect(websocket, close_code)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/tartiflette_asgi/_endpoints.py", line 116, in on_disconnect
    await self.protocol.on_disconnect(close_code)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/tartiflette_asgi/_subscriptions/impl.py", line 25, in on_disconnect
    await super().on_disconnect(close_code)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/tartiflette_asgi/_subscriptions/protocol.py", line 164, in on_disconnect
    await self._unsubscribe(opid)
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/tartiflette_asgi/_subscriptions/protocol.py", line 101, in _unsubscribe
    await subscription.aclose()
  File "/workspaces/serenity.core/venv/lib/python3.8/site-packages/tartiflette_asgi/_subscriptions/protocol.py", line 36, in aclose
    await self._agen.aclose()
RuntimeError: aclose(): asynchronous generator is already running

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