Skip to content

Commit 26fc75c

Browse files
committed
Merge branch 'deduplicate' into channels2
2 parents b81df97 + cdbdda1 commit 26fc75c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

graphql_ws/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def unsubscribe(self, op_id):
4343
async_iterator = self.remove_operation(op_id)
4444
if hasattr(async_iterator, 'dispose'):
4545
async_iterator.dispose()
46+
return async_iterator
4647

4748
def unsubscribe_all(self):
4849
for op_id in list(self.operations):

graphql_ws/base_async.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import inspect
33
from abc import ABC, abstractmethod
44
from types import CoroutineType, GeneratorType
5-
from typing import Any, Union, List, Dict
5+
from typing import Any, Dict, List, Union
66
from weakref import WeakSet
77

88
from graphql.execution.executors.asyncio import AsyncioExecutor
@@ -89,7 +89,12 @@ def remember_task(self, task):
8989
)
9090

9191
async def unsubscribe(self, op_id):
92-
super().unsubscribe(op_id)
92+
async_iterator = super().unsubscribe(op_id)
93+
if (
94+
getattr(async_iterator, "future", None)
95+
and async_iterator.future.cancel()
96+
):
97+
await async_iterator.future
9398

9499
async def unsubscribe_all(self):
95100
awaitables = [self.unsubscribe(op_id) for op_id in list(self.operations)]

0 commit comments

Comments
 (0)