Esempio n. 1
0
 async def customfilter(iterable):
     items = []
     async for item in auto_aiter(iterable):
         items.append(str(item))
         if len(items) == 3:
             break
     return ",".join(items)
Esempio n. 2
0
def test_async_iteration_in_templates_extended():
    t = Template(
        "{% for x in rng %}{{ loop.index0 }}/{{ x }}{% endfor %}", enable_async=True
    )
    stream = t.generate(rng=auto_aiter(range(1, 4)))
    assert next(stream) == "0"
    assert "".join(stream) == "/11/22/3"