@@ -68,7 +68,7 @@ async def on_start(self, connection_context, op_id, params):
68
68
await self .send_execution_result (
69
69
connection_context , op_id , execution_result
70
70
)
71
- await self .send_message (connection_context , op_id , GQL_COMPLETE )
71
+ await self .on_operation_complete (connection_context , op_id )
72
72
return
73
73
74
74
iterator = await execution_result .__aiter__ ()
@@ -80,7 +80,7 @@ async def run_op(self, connection_context, op_id, iterator):
80
80
if not connection_context .has_operation (op_id ):
81
81
break
82
82
await self .send_execution_result (connection_context , op_id , single_result )
83
- await self .send_message (connection_context , op_id , GQL_COMPLETE )
83
+ await self .on_operation_complete (connection_context , op_id )
84
84
85
85
async def on_close (self , connection_context ):
86
86
remove_operations = list (connection_context .operations .keys ())
@@ -90,20 +90,23 @@ async def on_close(self, connection_context):
90
90
if task :
91
91
cancelled_tasks .append (task )
92
92
# Wait around for all the tasks to actually cancel.
93
- await asyncio .gather ( * cancelled_tasks , return_exceptions = True )
93
+ await asyncio .wait ( cancelled_tasks )
94
94
95
95
async def on_stop (self , connection_context , op_id ):
96
96
task = await self .unsubscribe (connection_context , op_id )
97
- await asyncio .gather ( task , return_exceptions = True )
97
+ await asyncio .wait ([ task ] )
98
98
99
99
async def unsubscribe (self , connection_context , op_id ):
100
100
op = None
101
101
if connection_context .has_operation (op_id ):
102
102
op = connection_context .get_operation (op_id )
103
103
op .cancel ()
104
104
connection_context .remove_operation (op_id )
105
- self .on_operation_complete (connection_context , op_id )
105
+ await self .on_operation_complete (connection_context , op_id )
106
106
return op
107
107
108
+ async def on_operation_complete (self , connection_context , op_id ):
109
+ await self .send_message (connection_context , op_id , GQL_COMPLETE )
110
+
108
111
109
112
subscription_server = ChannelsSubscriptionServer (schema = graphene_settings .SCHEMA )
0 commit comments