Функция asyncio.wait() это еще один способ вызвать множество асинхронных задач.
Она работает в нескольких режимах.
1. Самый простой - ждем завершения всех задач
async def main():
tasks = [asyncio.create_task(do_it(i)) for i in range(10)]
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.ALL_COMPLETED
)
for task in done:
try:
print(task.result())
except Exception as e:
print(e)
Очень похоже на gather, но работает не так.
▫️возвращает не результаты, а два сета с объектами Task у которых можно забрать результат через task.result() если они в списке done
▫️не гарантирует порядок результатов так как оба объекта это set
▫️не выбрасывает исключение когда оно появляется, а сохраняет его в Task. Исключение появится когда попробуете забрать резултьтат.
2. Ждем завершения первой задачи, даже если там ошибка.
async def main():
tasks = [asyncio.create_task(do_it(i)) for i in range(3)]
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.FIRST_COMPLETED
)
# в done может быть несколько задач!
for task in done:
try:
print(task.result())
except Exception as e:
print(f"Fail: {e}")
# Оставшиеся задачи в pending, как правило, нужно отменить, иначе они будут продолжать работать
for task in pending:
task.cancel()
В сете done будут таски которые успели завершится, причем как успешно так и нет.
3. До первой ошибки.
Тоже самое, но с аргументом FIRST_EXCEPTION
done, pending = await asyncio.wait(
tasks,
return_when=asyncio.FIRST_EXCEPTION
)
Функция завершается как только первая задача упадет с ошибкой.
Учтите, что в любом случае done вы можете обранужить несколько задач, как с ошибками так и успешные.
↗️ Полный листинг примеров здесь
#async
⭐️#US30: Bulls Will Push Higher
It is essential that we apply multitimeframe technical analysis and there is no better example of why that is the case than the current 📈US30 chart which, if analyzed properly, clearly points in the upward direction.
#US30 SELL full Target done ☑️
Patience is a key 🔑 to success 🔥💰🤑🤑
Both Trade 700+Pips done 💯✅🚀🚀
VIP SIGNAL ON FIRE 🔥 always trust me guys and I will give you the best 💯.
Live Indices News Today – US30, NASDAQ, NAS100 & GER40 | March 23, 2026 https://www.fxpremiere.com/live-indices-news-today-us30-nasdaq-nas100-ger40-march-23-2026/#US30
🔅US30 Will Fall! Sell!📉
- - - - - - - -
Here is our detailed technical review for 📊US30.
The market is approaching a significant resistance area 49,454.8.
Due to the fact that we see a positive bearish reaction from the underlined area, I strongly believe that sellers will manage to push the price all the way down to 47,742.6 level.
- - - - - - - -
#freesignal#us30
- - - - - - - -
🌐Free Copy Trading: Link
📲Join VIP via Bot:Link
❓Official Contact:@signalprovidercontact
🔅US30 Is Bullish! Buy!📈
- - - - - - -
Here is our detailed technical review for 📊US30.
The market is testing a major horizontal structure 45,691.7.
Taking into consideration the structure & trend analysis, I believe that the market will reach 46,550.5 level soon.
- - - - - - - -
#freesignal#us30
- - - - - - - -
🌐Free Copy Trading: Link
📲Join VIP via Bot:Link
❓Official Contact:@signalprovidercontact
🔅US30 Will Grow! Long!📈
- - - - - - -
Here is our detailed technical review for 📊US30.
The market is trading around a solid horizontal structure 48,884.2.
The above observations make me that the market will inevitably achieve 49,692.2 level.
- - - - - - - -
#freesignal#us30
- - - - - - - -
🌐Free Copy Trading: Link
📲Join VIP via Bot:Link
❓Official Contact:@signalprovidercontact
🔅US30 Is Very Bearish! Short!📉
- - - - - - - -
Here is our detailed technical review for 📊US30.
The market is trading around a solid horizontal structure 50,088.7.
The above observations make me that the market will inevitably achieve 49,623.5 level.
- - - - - - - -
#freesignal#us30
- - - - - - - -
🌐Free Copy Trading: Link
📲Join VIP via Bot:Link
❓Official Contact:@signalprovidercontact
🔅US30 Will Move Lower! Sell!📉
- - - - - - - -
Take a look at our analysis for 📊US30.
The market is approaching a significant resistance area 49,481.0.
Due to the fact that we see a positive bearish reaction from the underlined area, I strongly believe that sellers will manage to push the price all the way down to 49,076.8 level.
- - - - - - - -
#freesignal#us30
- - - - - - - -
🌐Free Copy Trading: Link
📲Join VIP via Bot:Link
❓Official Contact:@signalprovidercontact
🔅US30 Is Bearish! Sell!📉
- - - - - - - -
Here is our detailed technical review for 📊US30.
The market is on a crucial zone of supply 49,331.6.
The above-mentioned technicals clearly indicate the dominance of sellers on the market. I recommend shorting the instrument, aiming at 48,745.5 level.
- - - - - - - -
#freesignal#us30
- - - - - - - -
🌐Free Copy Trading: Link
📲Join VIP via Bot:Link
❓Official Contact:@signalprovidercontact