@animal_fighting · Post #281 · 29.09.2022 г., 15:04
Crocodile VS Man One more way to deal with a toothy trespasser😀 #crocodile🐊
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
Пребарај: #crocodile
@animal_fighting · Post #281 · 29.09.2022 г., 15:04
Crocodile VS Man One more way to deal with a toothy trespasser😀 #crocodile🐊
Hashtags
@animal_fighting · Post #22 · 03.05.2022 г., 11:03
Crocodile VS Crocodile There hardly is a winner... #crocodile
Hashtags
@SukoFaultyArtLair · Post #4503 · 01.12.2019 г., 20:52
https://www.furaffinity.net/view/31997665/ #female#crocodile
Hashtags
@animal_fighting · Post #288 · 02.10.2022 г., 15:04
Lion VS Crocodile A dangerous opponent #lion🦁#crocodile🐊
Hashtags
@animal_fighting · Post #159 · 16.07.2022 г., 15:04
Crocodile VS Lions Too big and too sharp-toothed even for three lions #lion🦁#crocodile🐊
Hashtags
@animal_fighting · Post #94 · 11.06.2022 г., 07:03
Crocodile VS Lions It's too dangerous even for a lion pride #crocodile#lion
Hashtags
@animal_fighting · Post #29 · 07.05.2022 г., 07:03
Lions VS Crocodile When a prey is too dangerous even if being outnumbered #lion#crocodile
Hashtags
@animal_fighting · Post #333 · 09.11.2022 г., 19:04
Dog VS Crocodile Good reaction can save life... #dog#crocodile
Hashtags
@animal_fighting · Post #187 · 30.07.2022 г., 15:04
Dog VS Crocodile Terror of the jungle 😁 #dog🐕#crocodile🐊
Hashtags
@animal_fighting · Post #52 · 18.05.2022 г., 11:04
Buffalo VS Crocodile Unlucky hunting #buffalo#crocodile
Hashtags
@zigou23 · Post #136 · 28.04.2021 г., 03:27
抹茶旦旦 #鳄鱼#crocodile https://t.me/addstickers/mochadandan https://t.me/addstickers/mochadandan2 https://t.me/addstickers/mochadandan3 https://t.me/addstickers/mochadandan4_32 透明 https://t.me/addstickers/mcdd_tz 动态 https://t.me/addstickers/dxdongtai11_by_fStikBot https://t.me/addstickers/MoChaDanDan_EYu https://t.me/addstickers/mochadandan4
Hashtags
@animal_fighting · Post #268 · 25.09.2022 г., 10:04
Cat VS Crocodile Hunger makes one more courageous😀 #cat🐈#crocodile🐊
Hashtags