MCPcopy Index your code
hub / github.com/python/cpython / async_iterate

Method async_iterate

Lib/test/test_asyncgen.py:149–172  ·  view source on GitHub ↗
(g)

Source from the content-addressed store, hash-verified

147 return res
148
149 def async_iterate(g):
150 res = []
151 while True:
152 an = g.__anext__()
153 try:
154 while True:
155 try:
156 an.__next__()
157 except StopIteration as ex:
158 if ex.args:
159 res.append(ex.args[0])
160 break
161 else:
162 res.append('EMPTY StopIteration')
163 break
164 except StopAsyncIteration:
165 raise
166 except Exception as ex:
167 res.append(str(type(ex)))
168 break
169 except StopAsyncIteration:
170 res.append('STOP')
171 break
172 return res
173
174 sync_gen_result = sync_iterate(sync_gen)
175 async_gen_result = async_iterate(async_gen)

Callers

nothing calls this directly

Calls 4

strFunction · 0.85
__anext__Method · 0.45
__next__Method · 0.45
appendMethod · 0.45

Tested by

no test coverage detected