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

Резултати

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

Пребарај: #letter

当前筛选 #letter清除筛选
Pensive|

@PensivePost · Post #4889 · 07.02.2021 г., 23:34

Dear Love, I was passing thru a tunnel, deep, long, dense and drk tunnel full of the pain and agony, freaking and frustrating. It seems there was no end to this tunnel. In despair, i approached you, took your name, imagined your smile! And to my surprise, now the tunnel has ended. A bright beam of the light showing me a path ahead. Love, smiles, happiness all what I wished ahead. It feels like you filled my path with the sun light. Yes jaan, indeed you are the sunshine for me. And Love you love, for being there as bright light for me. Love you love, for bringing lots of happiness for me. Love you love, for gifting me the infinite togetherness. Love you 💕💕💕 #letter #review

Pensive|

@PensivePost · Post #5242 · 30.05.2021 г., 05:06

To the first friend, I made You are the reason to feel and realise what friendship is and how it feels. You brought happiness to my life. You were possessive on me. You were sad when i wasn't talk with you. You motivated me. You stood by my side. You were the one who scold when I do something wrong. I never thought that you left me and found a new best friend(s) But they love you more than me. I wish you to be happy and loved always not to be with me. We still communicate now and then. But not with the same Friendship just like a stranger. You fought with others to sit near with me but now you get over me and sit in other place even when there is no competition. I'm accepted the reality. I appreciate your choice of leaving me and get more loyal, true, lovely friends. I still hope you didn't forget my friendship with you #letter#review#friendshipbreakup