|
| 1 | +from asyncio import ensure_future |
1 | 2 | from inspect import isawaitable
|
2 | 3 | from graphene_django.settings import graphene_settings
|
3 | 4 | from graphql.execution.executors.asyncio import AsyncioExecutor
|
@@ -68,16 +69,21 @@ async def on_start(self, connection_context, op_id, params):
|
68 | 69 | await self.send_execution_result(
|
69 | 70 | connection_context, op_id, execution_result
|
70 | 71 | )
|
71 |
| - else: |
72 |
| - iterator = await execution_result.__aiter__() |
73 |
| - connection_context.register_operation(op_id, iterator) |
74 |
| - async for single_result in iterator: |
75 |
| - if not connection_context.has_operation(op_id): |
76 |
| - break |
77 |
| - await self.send_execution_result( |
78 |
| - connection_context, op_id, single_result |
79 |
| - ) |
80 | 72 | await self.send_message(connection_context, op_id, GQL_COMPLETE)
|
| 73 | + return |
| 74 | + |
| 75 | + iterator = await execution_result.__aiter__() |
| 76 | + ensure_future(self.run_op(connection_context, op_id, iterator)) |
| 77 | + |
| 78 | + async def run_op(self, connection_context, op_id, iterator): |
| 79 | + connection_context.register_operation(op_id, iterator) |
| 80 | + async for single_result in iterator: |
| 81 | + if not connection_context.has_operation(op_id): |
| 82 | + break |
| 83 | + await self.send_execution_result( |
| 84 | + connection_context, op_id, single_result |
| 85 | + ) |
| 86 | + await self.send_message(connection_context, op_id, GQL_COMPLETE) |
81 | 87 |
|
82 | 88 | async def on_close(self, connection_context):
|
83 | 89 | remove_operations = list(connection_context.operations.keys())
|
|
0 commit comments