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

Резултати

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

Пребарај: #idiom

当前筛选 #idiom清除筛选
English From Zero to Hero

@Learn_English_from_Zero_to_Hero · Post #60511 · 18.11.2025 г., 16:22

#Idiom 💢Go off on a tangent Or 💢 Go off at a tangent 🔰If a person or piece of writing goes off on a tangent or goes off at a tangent, they start saying or thinking something that is not directly connected with what they were saying or thinking before 💠Note:- In geometry, a tangent is a straight line which touches a curve at one point 🕸 Ex:- Our teacher would occasionally go off on a tangent and start talking about something totally unrelated to the textbook. 💠Note:- You can use other verbs instead of go 🕸 Ex:- The book's theme wandersoff on a tangent now and then.

Hashtags

English From Zero to Hero

@Learn_English_from_Zero_to_Hero · Post #59847 · 03.07.2025 г., 21:40

#Idiom 🕸People in society🕸 ❄️A self-made man ♣️ A person who is rich and successful because they have worked hard, not because they were born into a rich family ❄️The chattering classes ♣️ Educated people who enjoy discussing social, political and cultural issues ❄️A second-class citizen ♣️ Someone is treated as if they are less important than others in society ❄️The grass roots ♣️ Ordinary people in a political or sporting organisation, not the leaders ❄️ The silent majority ♣️ A large number of people who do not express their opinions publicly ❄️ The (men in) grey suits ♣️ People in business or politics with a lot of influence or power, although they are not well known to the public ❄️Public enemy number one ♣️ Smth or someone that a lot of people dislike or disapprove of ❄️New kid on the block ♣️ Someone who is new in a place or organisation and has many things to learn about it (informal).

Hashtags

English From Zero to Hero

@Learn_English_from_Zero_to_Hero · Post #59742 · 15.05.2025 г., 05:36

#Idiom 💢Even exchange: a trade of equal value; when you return something and take something else that costs the same price ✨ Ex: If you return that jacket and get this sweater instead, it will be an even exchange. They're both $39.99.

Hashtags

123•••10•••1213
ПретходнаСтраница 1 од 13Следна