Три способа выполнить множество задач с 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
The Co-optation of Continental Institutions: Abiy Ahmed’s Faustian Bargain with IGAD and the AU, and Its Inevitable Backfire on Ethiopian Stability. Read more.
https://borkena.com/2025/12/04/the-co-optation-of-continental-institutions-abiy-ahmeds-faustian-bargain-with-igad-and-the-au-and-its-inevitable-backfire-on-ethiopian-stability/#Ethiopia#politics#Africa#Institution
Ethnos to Demos: The Vision Confirmed, The Path Diverges. Read more.
https://borkena.com/2025/12/15/ethiopia-ethnos-to-demos-the-vision-confirmed-the-path-diverges/#Ethiopia#politics#institution#ethnicfederalism
📊Sanksiyani bartaraf etish, mintaqaviy integratsiya va institutlar
🟣Oliy maktabda Qozog‘iston Respublikasining Narxoz Universiteti professori Murat Issabayev ishtirokida “Sanksiyani bartaraf etish, mintaqaviy integratsiya va institutlar” mavzusidagiilmiy seminar bo‘lib o‘tdi.
💬Sanction Mitigation, Regional Integration, and the Role of Institutions
🟣The Graduate School hosted a scientific seminar titled "Sanctions Mitigation, Regional Integration, and Institutions," featuring Professor Murat Issabayev from Narxoz University, Kazakhstan.
🏙Устранение санкций, региональная интеграция и институты
🔴В Высшей школе состоялся научный семинарна тему «Устранение санкций, региональная интеграция и институты» с участием профессора Нархозского университета Республики Казахстан Мурата Иссабаева.
#GraduateSchool#Sanction#Integration#Institution
🔝Web-site |🔝Facebook | 🔝Instagram | 🔝Youtube
Fed's Role in Bitcoin Reserve Plans
Discussions arise on the establishment of a Bitcoin Strategic Reserve (BSR) if Trump decides to act quickly. The U.S. Treasury could use the Exchange Stabilization Fund to purchase Bitcoin via an executive order. Long-term stability requires congressional legislation to include Bitcoin in the Strategic Reserve Act. Both steps are Treasury-led, firmly placing the Federal Reserve outside of this decision-making process.
In another noteworthy development, blockchain project Trrue has secured a $10 million investment commitment from GEM Digital, despite GEM's background of fraudulent activity, raising concerns over transparency in reporting.
Read more: Wu Blockchain News | CoinDesk | Wu Blockchain News
#Fed#Bitcoin#BSR#UStreasury#ExecutiveOrder#Trrue#Investment#GEMDigital#Fraud#Blockchain#Transparency#Congress#ReserveAct#Crypto#Finance#News#Regulation#Market#Tokens#Ecosystem#Institution