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

Резултати

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

Пребарај: #iwd2024

当前筛选 #iwd2024清除筛选

Happy #InternationalWomensDay We recognise all women actively contributing to the strengthening of Nigeria's health security! We appreciate all women whose resilience and expertise drive positive change and accelerate progress in making our communities healthier, stronger, and more vibrant. #IWD2024

IRAS

@irassg · Post #846 · 08.03.2024 г., 03:15

📌 Did you know that you can use the IRAS Relief Checker to find out more about the tax reliefs and/or rebates you may be qualified for? Meet working mum Boon Hui, who is no stranger to the hectic, fast-paced life of the media industry. She’s thankful that despite the demanding schedule, her parents can help manage her teenage boys while she’s at work. She’s also appreciative of the tax reliefs and rebates which have considerably lightened the family’s financial load. This #internationalwomensday, we’d like to honour the strong women, families, friends and allies in our lives – for the seen and unseen labour they’ve carried at home and at work to help make our lives a little lighter. ❤ #iwd2024

🙋🏻‍♀️ Женщины, наделенные равными правами и возможностями - основа процветающего Узбекистана! 8️⃣ Поздравляем с Международным женским днем! #WomensDay#IWD2024#8марта

MAKON Marketing

@makonmarketing · Post #1452 · 07.03.2024 г., 06:27

🎉 Xalqaro xotin-qizlar kuniga tayyormisiz? 🤔 Qani, erkak kishini ilhomlantirib, hayoti va ishini yaxshilashga qodir ayol kimligini bilaylikchi! ✅ Bugun savolimizga Diyor Mirzaahmedov, O'zbekiston marketing assotsiatsiyasi raisining javobini e’tiboringizga taqdim etamiz. — #WomensDay#InspireInclusion#InvestInWomen#IWD2024