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

Пребарај: #ukgov

当前筛选 #ukgov清除筛选
AI & Law

@ai_and_law · Post #505 · 13.02.2025 г., 08:04

🇬🇧UK Government’s AI Playbook: A Roadmap for Safe AI Adoption The UK Government has introduced an AI Playbook to help public sector organizations navigate the complexities of AI adoption. This guide provides technical and governance frameworks to ensure AI is deployed effectively, securely, and in compliance with ethical and legal standards. It emphasizes the importance of AI literacy among civil servants, covering both the benefits and risks, from privacy concerns to security vulnerabilities. Key takeaways include: ✔️building an AI support structure, such as governance boards, adoption strategies, and training programs; ✔️ secure deployment practices, which categorize AI use cases — from public AI tools (ChatGPT, Claude) to privately hosted models and fine-tuned AI applications. This structured approach aims to balance innovation with accountability, ensuring AI serves the public interest. 🔹#AIRegulation#AIGovernance#UKGov#PublicSectorAI#ResponsibleAI

香港人的蘋果

@Appledailyhk26 · Post #55841 · 16.10.2023 г., 04:20

#英文#港聞 Several #HongKongers returned to Hong Kong from UK got arrested for getting their MPF (Mandatory Provident Fund). This is just an excuse for the #HKGov to punish #HongKongers for immigrating to the UK. The #UKGov must take action! 🍎保留一點真相、一些堅持: https://t.me/appledailyhk26 🍎蘋果報料熱線: @Appledailyhk_bot 🍎蘋民不蘋則鳴!2.0 https://t.me/hkerappledaily2