Skip to content

Commit 5f3f3be

Browse files
committed
subscribe: drop mapping of AsyncIterable errors
Replicates graphql/graphql-js@541a058
1 parent d3c1350 commit 5f3f3be

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

src/graphql/subscription/map_async_iterator.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,9 @@ class MapAsyncIterator:
1818
be closed.
1919
"""
2020

21-
def __init__(
22-
self,
23-
iterable: AsyncIterable,
24-
callback: Callable,
25-
reject_callback: Optional[Callable] = None,
26-
) -> None:
21+
def __init__(self, iterable: AsyncIterable, callback: Callable) -> None:
2722
self.iterator = iterable.__aiter__()
2823
self.callback = callback
29-
self.reject_callback = reject_callback
3024
self._close_event = Event()
3125

3226
def __aiter__(self) -> "MapAsyncIterator":
@@ -64,14 +58,10 @@ async def __anext__(self) -> Any:
6458

6559
error = anext.exception()
6660
if error:
67-
if not self.reject_callback or isinstance(
68-
error, (StopAsyncIteration, GeneratorExit)
69-
):
70-
raise error
71-
result = self.reject_callback(error)
72-
else:
73-
value = anext.result()
74-
result = self.callback(value)
61+
raise error
62+
63+
value = anext.result()
64+
result = self.callback(value)
7565

7666
return await result if isawaitable(result) else result
7767

tests/subscription/test_map_async_iterator.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -284,23 +284,6 @@ async def source():
284284

285285
assert str(exc_info.value) == "Goodbye"
286286

287-
@mark.asyncio
288-
async def maps_over_thrown_errors_if_second_callback_provided():
289-
async def source():
290-
yield "Hello"
291-
raise RuntimeError("Goodbye")
292-
293-
doubles = MapAsyncIterator(source(), lambda x: x + x, lambda error: error)
294-
295-
assert await anext(doubles) == "HelloHello"
296-
297-
result = await anext(doubles)
298-
assert isinstance(result, RuntimeError)
299-
assert str(result) == "Goodbye"
300-
301-
with raises(StopAsyncIteration):
302-
await anext(doubles)
303-
304287
@mark.asyncio
305288
async def can_use_simple_iterator_instead_of_generator():
306289
async def source():

0 commit comments

Comments
 (0)