queue = []
async def funcA():
r = random.randint(0, 1000)
i = 0
for i in range(10000000):
pass
print(r)
queue.append(r)
asyncio.create_task(funcb(r))
async def funcb(r):
i = 0
for i in range(100000000):
pass
print(r, "XX")
queue.pop()
async def main():
for i in range(10):
await funcA()
print(queue)
if __name__ == "__main__":
asyncio.run(main())
How do I make funcb() run simultaneously? In this code funcb() runs only after all calls of funcA() are done executing. I want funcB() to run concurrently with funcA() (on same or different threads). Here if funcA() runs infinitely, then funcB() would never run.
run_in_executorbut as other people say this isn't something you really want to do with asyncio