@QuietWorld · Post #7554 · 12.08.2020 г., 11:41
the tone and the way you talk about something, makes a difference. #fact@quietworld🍃
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
Пребарај: #fact
@QuietWorld · Post #7554 · 12.08.2020 г., 11:41
the tone and the way you talk about something, makes a difference. #fact@quietworld🍃
Hashtags
@QuietWorld · Post #6420 · 30.04.2019 г., 17:54
true 💯💯 #fact@quietworld🍃
Hashtags
@PlanetRong · Post #3482 · 11.02.2020 г., 17:18
#fact 我能听到 19500Hz 的声音。 20000Hz 有微弱听觉,戴上耳机能感觉到。 18000Hz 以下有较敏锐的听觉。 (我能确定听到的不是因为各种原因导致的杂音,高频正弦波的听感还是很好区分的
Hashtags
@whysoserioushmmm · Post #3470 · 26.04.2020 г., 11:30
Celebrities need us more than we need them. #fact
Hashtags
@whysoserioushmmm · Post #3274 · 20.03.2020 г., 09:57
Karma has no menu. You get served what you deserve. #fact @whysoserioushmmm
Hashtags
@whysoserioushmmm · Post #3266 · 19.03.2020 г., 06:40
Even though hand sanitizer kills 99.9% of germs, only 0.1% of germs actually make us sick #fact @whysoserioushmmm
Hashtags
@whysoserioushmmm · Post #3191 · 02.03.2020 г., 12:35
Bullet proof vests, fire escapes, windshield wipers and laser printers were all invented by women. #fact @whysoserioushmmm
Hashtags
@astronomic · Post #3032 · 10.10.2022 г., 17:13
Ceres accounts for one third of the mass in the asteroid belt. #Fact
Hashtags
@PlanetRong · Post #2997 · 07.01.2020 г., 17:28
#fact 两天总睡眠时间不足4h
Hashtags
@whysoserioushmmm · Post #2914 · 31.01.2020 г., 15:54
Vitamin D Doesn't come from the sun🌞; it comes from our skin. Sunlight☀️ is the factor that converts cholesterol in our skin to vitamin D3. #fact @whysoserioushmmm
Hashtags
@whysoserioushmmm · Post #2913 · 31.01.2020 г., 15:54
Mobile phones have 18 times more bacteria than Toilet🚽 Handles. #fact @whysoserioushmmm
Hashtags
@whysoserioushmmm · Post #2911 · 31.01.2020 г., 15:54
A 2014 study estimates that the human body consists of 39 trillion bacteria & 30 trillion human cells. #fact @whysoserioushmmm
Hashtags