Три способа выполнить множество задач с 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
🔰Airdrop: Ebees
💸Value: 8000 #EBS worth of ($12)
🪐Referral: 2000 $EBS for Each ($3)
⏳Distribution Date: After TGE
💎Ratings: ⭐️⭐️⭐️⭐️⭐️
🔗Airdrop Link: https://t.me/EbeesAirdropRound2Bot
Note: Airdrop will end on 5th September and rewards will be distributed to the winners TRC-20 wallet on after .
TGE September 6th 2022
Disclaimer: Please do your own research (DYOR) before joining to any airdrops project, also airdrop is 100% free. Don't send any fee or penny for receiving airdrop tokens. Also we don't recommend you to invest in any new projects, just join airdrop for free
#EBS Television founder Aman Fissehatsion dies
Aman Fissehatsion, founder and Chief Executive Officer of EBS Television, has died after receiving medical treatment for an illness, the station announced today, 11 February 2026.
In a statement issued Wednesday, EBS Television said Aman “played an irreplaceable role in the growth of #Ethiopian media and the success of EBS.” The station described him as “a man of outstanding vision,” adding that while his passing represents a loss to both his family and the institution, “the vision of Aman Fissehatsion will continue.”
The management and staff of EBS Television also expressed what they described as deep sorrow over his death.
Prime Minister #Abiy Ahmed (PhD) extended condolences following the announcement. In a message posted on his official Facebook page, the Prime Minister said Aman was “one of those who played a crucial role in the development of Ethiopia’s private media.”
https://www.facebook.com/share/p/189cm3oGQX/
#java#ai#apache_kafka#aws#azure#cloud#cloud_first#cloud_native#ebs#gcp#kafka#llm#messaging#minio#s3#serverless#spot#streaming
AutoMQ provides a cloud-native alternative to Apache Kafka that runs on S3 storage, cutting costs by up to 90% while enabling instant scaling and eliminating cross-zone traffic fees. It offers high reliability, serverless operation, and full Kafka compatibility, making it easier and cheaper to manage large-scale data streaming without sacrificing performance or features.
https://github.com/AutoMQ/automq