Три способа выполнить множество задач с 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
📰Group Appearance Settings
Upgrading your group will unlock new features for the group:
- Color and Profile Logo
- Group Status Emoji
- Group Theme and Wallpaper
- Group Emoji Pack
#Boost | #Groups
👉The TG Times
📰Group Custom Emoji Pack
Group Admins can set a Custom Emoji Pack for the group.
All members can use emojis from this pack in the group, even without ⭐️ Premium subscription.
#Boost | #Groups
👉The TG Times
📰Boost to send messages in the group
Group admins can choose how many boosts a user must give to the group to bypass restrictions on sending messages.
#Boost | #Groups
👉The TG Times
📰Boosting Groups
Changes in the configuration of Telegram for macOS show that it will be possible to boost groups.
After upgrading groups, the ability to set the background for the group, choose the status emoji and choose the emoji pack for the group will be added.
It seems that just as in groups, the special sticker pack for that group can be set, it will also be possible to choose the emoji pack.
Thanks to @tgcrawl
#Boost | #Groups
👉The TG Times
📰Boosting Groups
Changes in the configuration of Telegram for macOS show that it will be possible to boost groups.
After upgrading grouos, the ability to set the background for the group, choose the status emoji and choose the emoji pack for the group will be added.
It seems that just as in groups, the special sticker pack for that group can be set, it will also be possible to choose the emoji pack.
Thanks to @tgcrawl
#Boost | #Groups
👉The TG Times
📰Boosting Groups
Changes in the configuration of Telegram for macOS show that it will be possible to boost groups.
After upgrading grouos, the ability to set the background for the group, choose the status emoji and choose the emoji pack for the group will be added.
It seems that just as in groups, the special sticker pack for that group can be set, it will also be possible to choose the emoji pack.
Thanks to @tgcrawl
#Boost | #Groups
👉The TG Times
@TheNexasMusic_bot
Qué puede hacer este bot?
Con este bot puedes reproducir música nn grupos de telegram a través del chat de voz!
Idioma: Inglés
(visto en @BotsGram_cu)
#groups, #music
@Gramaphone_voice_bot
Qué puede hacer este bot?
Con este bot puedes reproducir música nn grupos de telegram a través del chat de voz!
Idioma: Inglés
(visto en @BotsGram_cu)
#groups, #music
@MultiForwardBot
Qué puede hacer este bot?
Este bot reenvía mensajes y medios de tu canal a grupos ilimitados de telegram!
Idioma: Inglés, Italiano, Español
(visto en @BotsGram_cu)
#channel, #groups