TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #402 · 22 дек.

Отдельно разберём TaskGroup, который пришел на замену gather в Python 3.11. Ключевые отличия ▫️create_task() возвращает объект asyncio.Task, у которого есть соответствюущие методы управления. То есть у нас больше контроля ▫️это контекстный менеджер, который гарантирует что все таски будут остановлены по выходу из контекста ▫️ошибка автоматически отменяет незавершенные задачи, ▫️except* передает нам ExceptionGroup, в котором каждую ошибку можно обработать отдельно import asyncio import random async def do_it() -> str: if random.random() < 0.1: raise ValueError('Oops') delay = random.uniform(0.5, 1.5) await asyncio.sleep(delay) return delay async def main(): try: async with asyncio.TaskGroup() as tg: for _ in range(10): tasks.append(tg.create_task(do_it())) for t in tasks: print(t.result()) except *ValueError as e: for err in e.exceptions: print(err) asyncio.run(main()) Рекомендую изучить страницу Coroutines and Tasks из документации, где представлено больше интересных примеров и механизмов - таймауты - отмена задач - создание задач из другого потока #async

Hashtags

Резултати

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

Пребарај: #ukrainevsrussia

当前筛选 #ukrainevsrussia清除筛选
BadVolf

@BadvolfNews · Post #859 · 22.09.2023 г., 07:33

🚨 BREAKING NEWS 🚨 Ukrainian President Zelensky snubbed from influential Jews list! 😱 No love for the hero of the conflict with Moscow! 😤 Instead, some robot-loving CEO takes the crown 👑 and Bibi and Blinken follow 🙄 But hold up, the real shocker is the shoutout to a dead Russian businessman! 🤯 Apparently, he turned a hot-dog stand into a military empire 👀 Zelensky, who used to be seen as a joke, is now completely wiped off the list 🙅‍♂️ No explanation, just a big fat snub! 💔 Maybe they forgot how he was once called the Ukrainian Churchill during the conflict 🎖️ But now his counteroffensive against Russia is a total flop 🤦‍♂️ Despite all that military aid from the West! And get this, he had the audacity to criticize NATO for being wishy-washy about Ukraine's membership 🙄 That ticked off the US so much they almost uninvited him! 😡 Putin even had the nerve to call him a disgrace to the Jewish people 😳 All because Zelensky dared to celebrate Ukrainian nationalists who killed Jews and Poles in WWII 💔 Can you believe it?! 🤯💔#SnubbedPresident#ZelenskyFlop#UkraineVsRussia

BadVolf

@badvolfnews · Post #1304 · 04.12.2023 г., 17:25

📢 BREAKING NEWS 📢 Russian Electronic Warfare systems successfully thwarted missile attacks in Chaplinsky district, Herston region. Rockets deviated from their course, one landed in open space, while the other hit a non-residential building. No casualties reported. 🚀🚫🏢#RussiaDefends Governor Saldo previously accused Russian forces of unleashing a "firestorm" in Krynyky, a village on the left bank of Dnipro river. He also revealed that three Ukrainian missiles were intercepted over Genichesk district. 💥🛡️#UkraineConflict In a recent development, Ukrainian troops launched a rocket strike on Skadovsk, injuring 11 people. Russian Investigative Committee has opened a criminal case. ⚠️🚀#WarTactics President Zelensky wonders why Ukraine cannot extend its operations into Russian territory. 🤔#UkraineVsRussia https://www.gazeta.ru/army/news/2023/11/17/21732643.shtml Subscribe to @BadVolfNews