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

Пребарај: #eff

当前筛选 #eff清除筛选
403 Forbidden

@forbid_403 · Post #283 · 14.03.2024 г., 06:31

EFF:呼吁议会停止对 Tik Tok 的封禁。 EFF 称议会不应根据社交媒体平台的运营者所属国家对其进行封禁;无论谁在收集数据,个人隐私都应受到保护。 https://act.eff.org/action/tell-congress-stop-the-tiktok-ban #EFF#TikTok#US

Addis Standard

@addisstandardeng · Post #21262 · 31.01.2026 г., 10:43

News: #Ethiopia submits 2028 AFCON bid, seeking fourth hosting after 50-year gap Ethiopia has formally submitted a bid to host the 2028 Africa Cup of Nations (#AFCON), seeking to stage the continental tournament for a fourth time and for the first time in more than five decades, according to a report by state-owned media citing the Ethiopian Football Federation (#EFF). The report said the bid was officially lodged with the Confederation of African Football (#CAF), marking Ethiopia’s return to contention for hosting the tournament it last staged in 1976. Ethiopia previously hosted AFCON in 1962, 1968, and 1976, and won the title on home soil in 1962. If awarded hosting rights, Ethiopia would become the joint second country to stage the Africa Cup of Nations the most times, behind only Egypt (5). Bahiru Tilahun, Secretary General of the Ethiopian Football Federation, was quoted in... https://www.facebook.com/AddisstandardEng/posts/pfbid02RBrfdanpeSSvrR4tcTWEyWrsRV4djoQDikrUvipckET9MttjzYM8t98rmQ3EG2o3l