Три способа выполнить множество задач с asyncio
Функция для примера:
async def do_it(n):
await asyncio.sleep(random.uniform(0.5, 1))
return n
1. Последовательный вызов
async def main():
for i in range(100):
result = await do_it(i)
Такой вызов имеет смысл только тогда, когда результат одной задачи требуется для вызова следующей.
Если они независимы, то это антипаттерн, так как аналогичен простому синхронному вызову по очереди.
2. Упорядоченный результат
async def main():
tasks = [do_it(i) for i in range(100)]
results = await asyncio.gather(*tasks)
Выполняет корутины конкурентно и возвращает результат в виде списка.
Полезен когда требуется получить результаты в том же порядке в котором задачи отправлены.
3. Результат по мере готовности
tasks = [asyncio.create_task(do_it(i)) for i in range(100)]
for cor in asyncio.as_completed(tasks):
result = await cor
Так же выполняет корутины конкурентно, но не гарантирует порядок. Результат возвращается по мере готовности, каждый отдельно.
Полезен когда нужно обработать любой ответ как можно скорее.
#async
Yes, you heard it right! The Future Minds Summit covers your airfare, meals, accommodation, and even your visa costs.
Eligibility: Open to Worldwide Participants
📍 Bangkok, Thailand 🇹🇭
🗓 Event Dates: 16-19 July 2026
⏳ Deadline: 16 June 2026
👉 Apply here: https://thegyn.org/fms-thailand/ (link in bio)
#FutureMindsSummit
#Thailand
#CallForDelegates#YouthLeadership#FundedOpportunity
FMST
📣 Call For Worldwide Applications!
The Future Minds Summit Thailand 🇹🇭 2026 invites motivated youth from across the world to take part in a global leadership and Intellectual dialogue on Sustainable Development Goals in Bangkok, Thailand
🎓 Theme: Exploring Sustainability through Innovative Minds
🌍 Open to Worldwide Participants
Scholarship Covers:
✈️ Airfare
🗄️ Visa Fees (if any)
🏨 Accommodation
🍽 Meals & Tea Breaks
📄 Visa support & Certification
🎙️ Speaking Opportunity at the Forum
🤝 All Social Activities & Cultural Fest
🗓 Event Dates: 16-19 July 2026
⏳ Deadline: 16 June 2026
👉 Apply here: https://thegyn.org/fms-thailand/
#FutureMindsSummit
#Thailand
#CallForDelegates#YouthLeadership#FundedOpportunity
Bangkok is Calling Future Leaders!
Visit: https://tinyurl.com/fms-thailand2026
Applications are now open for the GYN FutureMinds Summit 2026 in vibrant Bangkok, Thailand
Whether you're a student, graduate, or professional (ages 16–45), this is your chance to connect, learn, and lead on a global stage. No specific background required — just passion and vision!
What’s Covered?
Airfare
Accommodation
Meals & Tea Breaks
Visa Support & Fees (if applicable)
Speaking Opportunity
Cultural Fest & Social Activities
Certification
Join a diverse network of changemakers, gain international exposure, and make your voice heard where it matters.
Tag someone who shouldn’t miss this opportunity!
#FutureMindsSummit#FullyFunded#YouthLeaders#GlobalOpportunities#Bangkok2026#Changemakers#ApplyNow