MCPcopy
hub / github.com/scrapy/scrapy / iter_errback

Function iter_errback

scrapy/utils/defer.py:345–361  ·  view source on GitHub ↗

Wrap an iterable calling an errback if an error is caught while iterating it.

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

Source from the content-addressed store, hash-verified

343
344
345def iter_errback(
346 iterable: Iterable[_T],
347 errback: Callable[Concatenate[Failure, _P], Any],
348 *a: _P.args,
349 **kw: _P.kwargs,
350) -> Iterable[_T]:
351 """Wrap an iterable calling an errback if an error is caught while
352 iterating it.
353 """
354 it = iter(iterable)
355 while True:
356 try:
357 yield next(it)
358 except StopIteration:
359 break
360 except Exception:
361 errback(failure.Failure(), *a, **kw)
362
363
364async def aiter_errback(

Callers 3

test_iter_errback_badMethod · 0.90

Calls

no outgoing calls

Tested by 2

test_iter_errback_badMethod · 0.72