@LiveHealthy · Post #6940 · 24.01.2025 г., 00:52
#happiness
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
Пребарај: #happiness
@LiveHealthy · Post #6940 · 24.01.2025 г., 00:52
#happiness
Hashtags
@QuietWorld · Post #6796 · 26.10.2019 г., 08:30
The first recipe to happiness is to avoid lengthy meditation of the past. 🍃 #happiness@quietworld🍃
Hashtags
@QuietWorld · Post #6787 · 25.10.2019 г., 08:30
Happiness will never come to those who never appreciate what they already have. #happiness@quietworld🍃
Hashtags
@QuietWorld · Post #6756 · 20.10.2019 г., 23:30
Recall it as often as you wish, a happy memory never wears out. —Libbie Fudim #happiness@quietworld🍃
Hashtags
@QuietWorld · Post #6738 · 18.10.2019 г., 23:30
The word 'happiness' would lose its meaning if it were not balanced by sadness. – Carl Jung #happiness@quietworld🍃
Hashtags
@talks · Post #286 · 26.05.2018 г., 11:46
#happiness
Hashtags
@QuietWorld · Post #6772 · 23.10.2019 г., 08:30
Thousands of candles can be lighted from a single candle & the life of the candle will not be shortened. Happiness never decreased by being shared. – Buddha – but of course this doesn't apply to all kinds of happiness though, for example; I would surely be less happy if I were to share a husband with someone🧐 #happiness#thoughts @quietworld🍃
Hashtags
@QuietWorld · Post #6617 · 28.09.2019 г., 03:58
Happiness is not the absence of problems, but the ability to deal with them. #happiness#quotes @quietworld🍃
Hashtags
@QuietWorld · Post #6797 · 26.10.2019 г., 13:00
Happiness doesn't come from doing easy work but from the afterglow of satisfaction that comes after the achievement of a difficult task that demanded our best. #happiness#motivation @quietworld🍃
Hashtags
@QuietWorld · Post #7474 · 08.07.2020 г., 04:02
My ex-schoolmates, ex-collegemates, ex-everything on social media: • getting married • celebrating their first pregnancy • flexing new expensive car • flexing their lover • flexing their expensive pets 😍 Me: • happily flexing the stray kittens I adopted 🥰 The amount of happiness, is same 🥰 Just make sure you know what actually makes you happy 😄💐 What makes you happy? Comment down below.😉 #thoughts#life#happiness @quietworld🍃
Hashtags
@gumiho_wallpaper · Post #866 · 21.10.2024 г., 00:10
#Kdrama #Happiness
Hashtags
@QuietWorld · Post #6739 · 19.10.2019 г., 06:30
"Everyone wants happiness, nobody wants pains, but you can't have the rainbow, without a little rain." #happiness#selfreminder @quietworld🍃
Hashtags