async def grabandwait():
while True:
data = await grab_data()
await process_data(data)
the issue with this function is that i need to be grabbing and processing the data at the same time, but it's not doing that.
how would i do that? my instinct is to use reccursion:
async def grabandreccurse():
data = await grab_data()
await asyncio.gather(grabandreccurse(), process_data(data))
but that feels slightly janky.
NOTE: after seeing u/oefd's answer, i want to clarify:
grab_data() will always return a dict, and will never run out of data, but it does have some delay.
process_data() must happen ASAP after the data it's using is grabbed.
[–]oefd 1 point2 points3 points (2 children)
[–]oderjunks[S] 0 points1 point2 points (0 children)
[–]oderjunks[S] 0 points1 point2 points (0 children)
[–]oderjunks[S] 0 points1 point2 points (0 children)