File tree Expand file tree Collapse file tree 2 files changed +5
-32
lines changed Expand file tree Collapse file tree 2 files changed +5
-32
lines changed Original file line number Diff line number Diff line change @@ -18,15 +18,9 @@ class MapAsyncIterator:
18
18
be closed.
19
19
"""
20
20
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 :
27
22
self .iterator = iterable .__aiter__ ()
28
23
self .callback = callback
29
- self .reject_callback = reject_callback
30
24
self ._close_event = Event ()
31
25
32
26
def __aiter__ (self ) -> "MapAsyncIterator" :
@@ -64,14 +58,10 @@ async def __anext__(self) -> Any:
64
58
65
59
error = anext .exception ()
66
60
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 )
75
65
76
66
return await result if isawaitable (result ) else result
77
67
Original file line number Diff line number Diff line change @@ -284,23 +284,6 @@ async def source():
284
284
285
285
assert str (exc_info .value ) == "Goodbye"
286
286
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
-
304
287
@mark .asyncio
305
288
async def can_use_simple_iterator_instead_of_generator ():
306
289
async def source ():
You can’t perform that action at this time.
0 commit comments