MCPcopy
hub / github.com/scrapy/scrapy / aiter_errback

Function aiter_errback

scrapy/utils/defer.py:364–380  ·  view source on GitHub ↗

Wrap an async iterable calling an errback if an error is caught while iterating it. Similar to :func:`scrapy.utils.defer.iter_errback`.

(
    aiterable: AsyncIterator[_T],
    errback: Callable[Concatenate[Failure, _P], Any],
    *a: _P.args,
    **kw: _P.kwargs,
)

Source from the content-addressed store, hash-verified

362
363
364async def aiter_errback(
365 aiterable: AsyncIterator[_T],
366 errback: Callable[Concatenate[Failure, _P], Any],
367 *a: _P.args,
368 **kw: _P.kwargs,
369) -> AsyncIterator[_T]:
370 """Wrap an async iterable calling an errback if an error is caught while
371 iterating it. Similar to :func:`scrapy.utils.defer.iter_errback`.
372 """
373 it = aiter(aiterable)
374 while True:
375 try:
376 yield await anext(it)
377 except StopAsyncIteration:
378 break
379 except Exception:
380 errback(failure.Failure(), *a, **kw)
381
382
383@overload

Callers 5

iterate_spider_outputMethod · 0.90
test_iter_errback_badMethod · 0.90

Calls

no outgoing calls

Tested by 3

test_iter_errback_badMethod · 0.72