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

Пребарај: #stayhydrated

当前筛选 #stayhydrated清除筛选

#WellnessWednesday: The Power of Hydration Water is more than just a thirst quencher, it's essential for energy, brain function, digestion, toxin removal, and overall physical performance. ✔️Make hydration a daily priority for a healthier, stronger you. #WellnessWednesday#StayHydrated#HealthyLiving#NCDCNigeria#PublicHealth

Health & Safety TIPS

@PrimalTips · Post #2732 · 07.06.2024 г., 07:20

🌱 Today's Health Tip: The Power of Hydration Staying hydrated is crucial for maintaining good health. Water helps regulate body temperature, aids digestion, and keeps your skin healthy. 💧 Aim to drink at least 8 glasses of water a day, more if you're active or in hot weather. 🥤 Remember, staying hydrated doesn't just mean water. You can also get fluids from fruits, vegetables, and herbal teas. 🍉🥒 Incorporating water-rich foods like watermelon and cucumber into your diet can also help keep you hydrated throughout the day. Stay hydrated, stay healthy! 💦#HealthTips#StayHydrated#WellnessWednesday 🗂Source : @HeathSafetyTps ♻️SHARE NOW

#HealthTipMonday – Stay Hydrated, Especially in This Hot Weather! The heat right now is INTENSE 🥵 💧 Dehydration can sneak up on you, causing headaches, fatigue, dizziness, and even heat exhaustion. Staying hydrated is key to staying healthy in this heat! ✅ Drink at least 8 glasses of water daily : You lose more fluids when it’s hot, so drink up! ✅ Avoid sugary drinks : They can worsen dehydration. Stick to water, coconut water, or natural fruit juices. ✅ Carry a reusable water bottle : Always have water handy, whether at work, home, or on the go. ✅ Eat water-rich foods : Snack on watermelon, cucumbers, oranges, and pineapples to boost hydration. ✅ Watch for dehydration signs : Dry mouth, dark urine, and dizziness mean you need more water! 🚰 Don’t wait till you’re thirsty, drink water regularly! Stay cool, stay hydrated, and stay safe in this heat. #HealthTipMonday#StayHydrated#BeatTheHeat#NCDCNigeria