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 слични објави

Пребарај: #henoa

当前筛选 #henoa清除筛选
Quiet World 🍁

@QuietWorld · Post #7416 · 17.06.2020 г., 04:12

I sprayed her butt just a little with hand sanitizer because she keeps on biting wires on the desk.. I swear just a little 🥺 & she slowly sit there, lying down, with her eyes looking at me for a while until slowly falls asleep 🥺 she stopped biting the wires but I feel bad 🥺 Is she sad? or just tired? 🥺 #random#Henoa @quietworld🍃

Quiet World 🍁

@QuietWorld · Post #7401 · 15.06.2020 г., 06:42

Today, a thought strucked me; I love looking at cats especially high breed cat but I never wanted to buy and take care of high breed cat because I'm scared that I'm not able to take good care of it since high breed requires high maintenance.. So, I only wanted to take care of village cat, but then, I treat the village cat like high breed cat 😂 So.. why was I scared to adopt/buy high breed cat, right? I treat my village cat like royal anyway 😂 * currently waiting for my kitten to come back from home-based grooming service (waiting anxiously) * I hope she comes back here safe 🥺😢 #thoughts#cat#Henoa @quietworld🍃

Quiet World 🍁

@QuietWorld · Post #7402 · 15.06.2020 г., 07:48

Yeyy she's finally back from grooming 😍 Her nails clipped, ears cleaned and she smells good ☺❤ I'll get no more scars because her habit of climbing me 🤣 for now.. until her nails grow long and sharp again 🤣 Worth the wait.. from 12:30PM until 03:40PM🥰 #cat#Henoa#chupdate @quietworld🍃

Quiet World 🍁

@QuietWorld · Post #7450 · 27.06.2020 г., 23:02

Shopping for Henoa le Kitten again! 😍 Unplanned but I found item that I didn't know exist before that I think Henoa & I needs and I read lots of reviews saying that this shop sells a lot cheaper than other stores so why not? 😂 Will be making a video of unboxing these + review once they arrived and tested 🥰💞 Stay tuned for this video upload in my channel 🥰 #marcegetaway#youtube#kitten#Henoa @quietworld🍃