TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

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

Резултати

Пронајдени 3 слични објави

Пребарај: #shows

当前筛选 #shows清除筛选
Car News

@car_news · Post #1225 · 25.04.2025 г., 09:47

📺Top Gear is back 📱 The first series of 'documentary comedy' The Not Very Grand Tour with the iconic show's presenters has been released. ℹ️The episode focuses on the memories of May, Hammond and Clarkson. It included an oil-car race through Detroit, a tank drive and the bombing of Clarkson's house. All in the name of internal combustion engines. 📆 There will be four episodes in total. The rest are due this year and 2026. @CarsNews #shows

Hashtags

One Piece (TV Series) Year of Production: 2023 Countries: USA, UK, Japan Filming Location: South Africa Genres: Adventure, Fantasy, Comedy, Action A fearless young captain assembles a diverse crew and embarks on an epic journey to become the King of the Pirates by uncovering a legendary treasure. This television series is a live-action adaptation of the iconic manga One Piece by Eiichiro Oda. The show received widespread acclaim from both critics and fans for its engaging storytelling and faithful adaptation. Part of the series was filmed at Cape Town Film Studios in South Africa. 🎥Official trailer. #movies#shows#series#culture