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

Резултати

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

Пребарај: #anc113

当前筛选 #anc113清除筛选
Russian Consulate in Cape Town

@rusconct · Post #2143 · 12.01.2025 г., 14:08

🇷🇺🇿🇦Ambassador of Russia to South Africa Roman Ambarov attended the celebration of the 113th anniversary of the formation of the African National Congress in Cape Town. «To quote Oliver Tambo, the formation of the ANC was a continuation in Southern Africa, under new historic conditions, of the anti-colonial and national liberation struggles which had begun with the advent of colonialism. The Soviet Union, throughout its entire history, consistently stood for the elimination of colonialism and supported liberation movements in Africa and across the globe,” the Ambassador said on the sidelines of the event. “However, the work on decolonization spearheaded by the USSR in the XX century was not finished. And today Russia and South Africa are among the most vigorous supporters of anti-neocolonial policies,” Roman Ambarov pointed out. 🤝The ANC participates in the work of the international forum “For the Freedom of Nations!” seeking to wipe out modern practices of neocolonialism. In Dec 2024, Pretoria voted for the UNGA resolution on the eradication of colonialism in all its forms and manifestations. “We hope our collaboration will help mobilize all responsible members of the international community to uphold justice in world affairs,” the Ambassador added. #RussiaSouthAfrica#RussiaSArelations#StopColonialism#StopColonialismNow#Ambarov#ANC113Anniversary#ANC113@MYANC