Answer the question
In order to leave comments, you need to log in
How to implement for using Asyncio?
Good afternoon. I can't figure out how to implement a loop using Asyncio.
There are, let's say, 5 requests, for which you first need to make the first request and get the authorization code, then use it to make the second request. I want this to be implemented through Asyncio, so as not to wait for answers. How to do this, tell me.
Answer the question
In order to leave comments, you need to log in
To give the most correct answer, it is desirable to know the details of the problem. But in the most general case, this is solved by a chain of coroutines:
async def third_task():
# Какие-то асинхронные действия
return something
async def second_task():
r = await third_task()
# Какие-то действия с результатом в переменной r
return processed_r
async def first_task():
r = await second_task()
# Какие-то действия с результатом в переменной r
asyncio.run(first_task())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question