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

Резултати

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

Пребарај: #jinpooh

当前筛选 #jinpooh清除筛选
Telegraher

@Telegraher · Post #519 · 26.07.2022 г., 20:55

Folks, some handy tips: • read comments before commenting • vanilla tg OR our fork also have "translate" button If you commenting w/o reading the discussion.. Well, go on reddit 😁 More details: post about Nekogram picked up from NekoX chat. Moar details: • Nekogram is a bitch who ban you for political reasons and opinions like 1989 #JinPooh#freetibet#西藏独立运动#西藏独立 . • NekoX can be a bitchie and ban you when you critic Durov or TG TOS but they always unban you, while i'm still banned in Nekogram chat (i was banned twice in both and forever in Nekogram). My political messages are still in NekoX chat 😎

Telegraher

@Telegraher · Post #516 · 23.07.2022 г., 08:55

Hallo folks, fond this stuff in NekoX chat: https://github.com/NekogramX/Nekogram - link is fuckedup by github probably (upd). Fake it or not?.. Well, nekogram assholes are banned me also for politic content: 1989 #JinPooh#freetibet#西藏独立运动#西藏独立 Here https://t.me/telegraher/74 And here https://t.me/telegraher/95 https://t.me/telegraher/97 Ban + wipe any forbidden in china content. Text translated by chinese guy from nekox chat, original messages are in our chat. P.S. NekoX are bitchies also, but a much less, they're just for TG's TOS & Durov, not the chinese Gov, thats important différence. FREETIBET !