import asyncio
async def get_some_values_from_io():
# Some IO code which returns a list of values
...
vals = []
async def fetcher():
while True:
io_vals = await get_some_values_from_io()
for val in io_vals:
vals.append(io_vals)
async def monitor():
while True:
print (len(vals))
await asyncio.sleep(1)
async def main():
t1 = asyncio.create_task(fetcher())
t2 = asyncio.create_task(monitor())
await asyncio.gather(t1, t2)
asyncio.run(main())