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

Пребарај: #technologyinnovation

当前筛选 #technologyinnovation清除筛选
Crypto M - Crypto News

@CryptoM · Post #65247 · 12.04.2026 г., 09:19

🚀 STOCKS | Galaxy Securities Highlights Opportunities Amid Rising Oil Prices On April 12, Galaxy Securities released a report noting that March's Producer Price Index (PPI) turned positive year-on-year, driven by high oil prices and ongoing policy efforts. According to Jin10, the report emphasizes the potential for profit recovery in China's A-share market, particularly in upstream sectors. The report identifies several investment opportunities. Firstly, it suggests focusing on energy and alternative demand sectors, including coal, coal chemicals, new energy, shipping ports, and oil and gas. Additionally, there is potential for recovery in the non-ferrous metals sector, including precious and minor metals. Secondly, the report highlights defensive assets such as finance (banks), utilities, and transportation. Thirdly, it points to technology innovation and self-sufficiency sectors, including power equipment, energy storage, semiconductors, computing power, and communication equipment. In the consumer sector, it suggests focusing on agriculture, forestry, animal husbandry, fisheries, food and beverages, and household appliances. The report also notes that if there are signs of easing in ongoing conflicts, there could be significant recovery opportunities in previously oversold sectors. #GalaxySecurities#OilPrices#ProducerPriceIndex#ProfitRecovery#AShareMarket#UpstreamSectors#EnergySector#AlternativeDemand#Coal#NewEnergy#ShippingPorts#OilAndGas#NonFerrousMetals#PreciousMetals#DefensiveAssets#Finance#Utilities#Transportation#TechnologyInnovation#SelfSufficiency#PowerEquipment#EnergyStorage#Semiconductors#ComputingPower#CommunicationEquipment#ConsumerSector#Agriculture#FoodAndBeverages#HouseholdAppliances#RecoveryOpportunities