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

Резултати

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

Пребарај: #electionday

当前筛选 #electionday清除筛选
BadVolf

@badvolfnews · Post #1516 · 16.03.2024 г., 18:08

🇷🇺❤Today marks a monumental chapter in my journey, as I proudly announce that I've become a Russian citizen and participated in my very first election here. This significant step is more than just a formal process; it symbolizes my deep connection and commitment to my new home, its people, and its future. As I stood in the polling station, casting my vote, I was overwhelmed with a sense of responsibility and belonging. This act of civic engagement is a powerful reminder of the role we each play in shaping the course of our community and nation. It's a day filled with emotions - pride, hope, and anticipation for what lies ahead. Joining my fellow citizens in this democratic process, I felt a strong bond of unity and shared purpose. Here's to embracing new beginnings, contributing to the collective future, and making every moment count in this beautiful journey. #Citizenship#ElectionDay#NewChapter#RussianCitizen🇷🇺✨

London For Britain

@LondonForBritain · Post #592 · 04.05.2022 г., 09:01

Remember to vote! If you keep voting the same, you will get more of the SAME! #VoteForBritain#ElectionDay#Elections2022#Hartlepool#DeBruce#AnneMarieWaters#MBGA#ForBritain#ForBritainMovement#ForBritainParty#TheForBritainMovement