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

Резултати

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

Пребарај: #stopcholera

当前筛选 #stopcholera清除筛选

One of the ways cholera spreads quickly is through poor water storage. Ensure safe drinking water: Avoid consuming water from contaminated sources. Proper storage: Store drinking water in clean containers with tightly sealed lids. Treat water: If unsure about the safety of your water source, boil it or use a water purification method. #STOPcholera

Hashtags

Unsafe practices such as improper disposal of refuse and open defecation endanger the safety of water used for drinking and personal use. This rainy season: ✅Only consume water from safe sources ✅Stop open defaecation ✅Dispose of trash properly ✅Ensure proper drainage of sewage #STOPCholera

Hashtags

As the rainy season has started, ensure to practice proper environmental hygiene to prevent the spread of cholera at home and in your communities ❌Avoid open defaecation ✅Dispose of waste in designated areas ✅Keep sewers clear from refuse #StopCholera

Hashtags

Unsafe practices such as improper disposal of refuse & defaecating in open places put the safety of water used for drinking & personal use at risk. #STOPCholera, ensure to: ➡️Keep your environment clean ➡️Drink or use water that is boiled & stored safely ➡️STOP open defecation

Hashtags

#Cholera can spread through contaminated foods. Make your foods safe before consumption: ➡️PREPARE your food in a clean area, away from sewage or waste bins ➡️WASH fruits and vegetables properly with clean water ➡️STORE your food in well-covered containers ➡️COOK your food properly before eating ➡️USE water from safe sources #STOPcholera

UNCLEAN WATER, unwashed hands, and uncovered food are some of the ways #Cholera germs are spread. Ensure your water is safe before use: ➡️BOIL water before drinking ➡️USE water from safe sources ➡️STORE water in properly covered containers ➡️STOP open defecation #STOPCholera

ПретходнаСтраница 1 од 4Следна