Skip to content

Commit dcc20a9

Browse files
committed
Fix task getter if there’s no longer a running loop
1 parent 41fe983 commit dcc20a9

File tree

1 file changed

+5
-1
lines changed
  • src/graphql_server/subscriptions/protocols/graphql_transport_ws

1 file changed

+5
-1
lines changed

src/graphql_server/subscriptions/protocols/graphql_transport_ws/handlers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,11 @@ async def run_operation(self, operation: Operation[Context, RootValue]) -> None:
334334
raise
335335
finally:
336336
# add this task to a list to be reaped later
337-
task = asyncio.current_task()
337+
try:
338+
task = asyncio.current_task()
339+
except RuntimeError:
340+
# If there's no running loop
341+
return
338342
assert task is not None
339343
self.completed_tasks.append(task)
340344

0 commit comments

Comments
 (0)