@desi_memes_funny_jokes · Post #4688 · 02.06.2024 г., 05:34
#funnymemes#reels
Hashtags
TGINSIGHT SIMILAR POSTS
Изворен канал @pythonotes · Post #401 · 15 дек.
Функция 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
Hashtags
Пребарај: #funnymemes
@desi_memes_funny_jokes · Post #4688 · 02.06.2024 г., 05:34
#funnymemes#reels
Hashtags
@desi_memes_funny_jokes · Post #4694 · 02.06.2024 г., 15:35
#funnyreels#funnymemes
Hashtags
@DESI_MEMES_Funny_Jokes · Post #5828 · 09.11.2024 г., 16:55
Phir se fail hoga😭 . . . . . . . . Memes funny funnyvideos funnymemes comedy explore new video . . #memes#funnymemes#explore#funny#funnyvideos#comedy
@DESI_MEMES_Funny_Jokes · Post #5826 · 09.11.2024 г., 15:49
M€mory😭 . . . . . . . . . Memes funny funnyvideos funnymemes comedy explore new video . . #memes#funnymemes#funny#funnyvideos#explore#comedy
@DESI_MEMES_Funny_Jokes · Post #5825 · 09.11.2024 г., 15:02
H!gh 0n pr0tien😂 . . . . . Memes funny funnyvideos funnymemes comedy explore new video . .. . #memes#funnymemes#funny#funnyvideos#explore#comedy
@DESI_MEMES_Funny_Jokes · Post #5822 · 09.11.2024 г., 14:06
Lull! T0uching sh0t😭 . . . . . . . . Memes funny funnyvideos funnymemes comedy explore new video . . #memes#funnymemes#funny#funnyvideos#explore#comedy
@DESI_MEMES_Funny_Jokes · Post #5821 · 09.11.2024 г., 13:19
Urf!'s 0utfit😭 . . . . . . . . . Memes funny funnyvideos funnymemes comedy explore new video . . #memes#funnymemes#funny#funnyvideos#comedy#explore
@DESI_MEMES_Funny_Jokes · Post #5566 · 25.10.2024 г., 14:47
Comfy ☺️ #memes#funnymemes#explore#funny#funnyvideos#comedy
@DESI_MEMES_Funny_Jokes · Post #5446 · 16.10.2024 г., 05:17
Pl£ase l£ave me al0ne😭 . . . . . . . . . . . . Memes funny funnyvideos funnymemes comedy explore new video . . #memes#funnymemes#explore#comedy#funny#funnyvideos
@DESI_MEMES_Funny_Jokes · Post #5415 · 10.10.2024 г., 12:10
Wh@ts h£r @? . . . . . . . . . Memes funny funnyvideos funnymemes comedy explore new video . . #memes#explore#funnymemes#comedy#funny#funnyvideos
@desi_memes_funny_jokes · Post #5357 · 02.10.2024 г., 14:53
Br!lliant😭 . . . . . . . . . . . Memes funny funnyvideos funnymemes comedy explore new video . . #memes#explore#funnymemes#comedy#funny#funnyvideos
@desi_memes_funny_jokes · Post #5351 · 01.10.2024 г., 07:20
£at gr££n😅 . . . . . . . . . Memes funny funnyvideos funnymemes comedy explore new video . . #memes#funnymemes#explore#comedy#funny#funnyvideos