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

Резултати

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

Пребарај: #single

当前筛选 #single清除筛选
Андрей Лаупер

@free4ones · Post #545 · 29.08.2024 г., 06:24

📻 Годы работы в эфире музыкальных радиостанций не проходят бесследно - тяга к микрофону и к свежим реализам не исчезает😎 💿 Свежий летний попсовый сингл из чарта UK TOP 40: Fred again.. / Anderson .Paak / CHIKA - Places To Be Британцы в очередной раз удивляют своей прогрессивностью и технологичным продакшном. #single#summer

探索号

@seeker_rc · Post #19839 · 07.05.2026 г., 03:25

大家是怎么管理和检索 SingleFile 保存的网页的? 长期都是用 single file 保存网页,但发现自己想用的时候,却始终找不到自己保存,目前想到的解决方案是自动 rag 清洗检索,但总觉得这玩意儿之前应该有人做过了吧 via V2EX 分享创造 标签: #网页#SingleFile#single ⚡️探索号频道 ⚡️探索者频道 ⚡️探索者交流群 ⚡️ Youtube 频道:科技探索者 每天推荐有趣内容,欢迎订阅、转发。

djangoproject

@djangoproject · Post #107 · 02.08.2016 г., 15:22

https://github.com/python/asyncio The #asyncio#module provides infrastructure for writing #single-threaded concurrent code using #coroutines, #multiplexing#I/O access over sockets and other resources, running network clients and servers, and other related primitives. Here is a more detailed list of the package contents: a pluggable event loop with various system-specific implementations; transport and protocol abstractions (similar to those in Twisted); concrete support for TCP, UDP, SSL, subprocess pipes, delayed calls, and others (some may be system-dependent); a Future class that mimics the one in the concurrent.futures module, but adapted for use with the event loop; #coroutines and #tasks based on yield from (PEP 380), to help write concurrent code in a sequential fashion; cancellation support for Futures and coroutines; synchronization primitives for use between coroutines in a single thread, mimicking those in the #threading module; an interface for passing work off to a threadpool, for times when you absolutely, positively have to use a library that makes blocking I/O calls. Note: The implementation of asyncio was previously called "Tulip".

Desi Memes Funny Jokes

@DESI_MEMES_Funny_Jokes · Post #6008 · 10.12.2024 г., 12:03

. . . . . #crusheverything#crush#crushlovers#sendthistoyourcrush#crushmemes#crushrejection#crush😍#crushquote#love#lovecrush#singlelifeproblems#singlefriends#singleme#singlelifebelike#singlemen#singleboy#single#boyswillbeboys#boystory#boysdream#boyslife#boyscanrelate#relatable#relatablememes#reelsinstagram#reelfeelit#explore#exploremoretogether

Desi Memes Funny Jokes

@DESI_MEMES_Funny_Jokes · Post #5425 · 12.10.2024 г., 05:03

Earphone laga lena bhai 🎧 . #crusheverything#crush#crushlovers#sendthistoyourcrush#crushmemes#crushrejection#crush😍#crushquote#love#lovecrush#singlelifeproblems#singlefriends#singleme#singlelifebelike#singlemen#singleboy#single#boyswillbeboys#boystory#boysdream#boyslife#boyscanrelate#relatable#relatablememes#reelinstagram#reelfeelit#explore#exploremore