MCPcopy
hub / github.com/scrapy/scrapy / as_async_generator

Function as_async_generator

scrapy/utils/asyncgen.py:13–22  ·  view source on GitHub ↗

Wraps an iterable (sync or async) into an async generator.

(
    it: Iterable[_T] | AsyncIterator[_T],
)

Source from the content-addressed store, hash-verified

11
12
13async def as_async_generator(
14 it: Iterable[_T] | AsyncIterator[_T],
15) -> AsyncGenerator[_T]:
16 """Wraps an iterable (sync or async) into an async generator."""
17 if isinstance(it, AsyncIterator):
18 async for r in it:
19 yield r
20 else:
21 for r in it:
22 yield r

Callers 13

_async_chainFunction · 0.90
fill_queueFunction · 0.90
scrape_response_asyncMethod · 0.90
test_collect_asyncgenMethod · 0.90
get_async_iterableMethod · 0.90
get_async_iterableMethod · 0.90
test_trivialFunction · 0.90
test_processed_requestFunction · 0.90
test_processed_itemFunction · 0.90

Calls

no outgoing calls

Tested by 9

test_collect_asyncgenMethod · 0.72
get_async_iterableMethod · 0.72
get_async_iterableMethod · 0.72
test_trivialFunction · 0.72
test_processed_requestFunction · 0.72
test_processed_itemFunction · 0.72
test_processed_bothFunction · 0.72