Отдельно разберём 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
🌎 The Voyager 1 spacecraft captured “plasma wave” sounds as it entered interstellar space in 2012. These sounds are actually electromagnetic vibrations in space, converted into audio by NASA scientists. The pitch and intensity help scientists measure the density of charged particles beyond our Solar System. ✨
#Voyager⚡#space⚡#sound
👉subscribe Interesting Planet
👉more Channels
🚨🚨#Voyager has moved $99M worth of digital assets over the past 48 hours. ⬅️ $60.6M in various tokens to #Binance, #Coinbase & #Wintermute ⬅️ $38.6M (25K $ETH) to 5 unknown wallets. ➡️ Received ~62M USDC from exchanges. Still holds $767.7M worth of assets…
🚨🚨#Voyager has moved $99M worth of digital assets over the past 48 hours.
⬅️ $60.6M in various tokens to #Binance, #Coinbase & #Wintermute
⬅️ $38.6M (25K $ETH) to 5 unknown wallets.
➡️ Received ~62M USDC from exchanges.
Still holds $767.7M worth of assets (likely sold more in upcoming days)
🌎 Exploring the edge of the solar system, NASA’s Voyager 1 spacecraft became the first human-made object to enter interstellar space in 2012. It carries instruments to measure cosmic rays, magnetic fields, and particles beyond the Sun’s influence—data still transmitted from over 24 billion kilometers away. ✨
#space⚡#voyager⚡#interstellar
👉subscribe Interesting Planet
👉more Channels
¡New build available!
#A15#BlissRom
Xiaomi 12T Pro / Redmi K50 Ultra (diting)
Maintainer:@TeamMEX_XDA (Kισżż)
Version:Bliss-v18.1-diting-UNOFFICIAL-gapps-20250112
Download
Firmware
Device Changelog:
- Fix eSIM (forgot to add the wrapper)
- Include the firmware again
- Allow people to flash stuff via bliss recovery (you can still use ofox or twrp)
- Fix Misight domain sepolicy issues
- Implement rebased yuki kernel (again is fixed the issues on 12tPRO? )
- FW included
- Feas support
- FEAS: Code refactoring to improve efficiency and readability.
'#BlissRom' '#Voyager' '#Bliss18.1'
If you like my work and want to support it please consider making a donation this helps with server costs.
Donate PayPal
¡New build available!
#A15#BlissRom
Xiaomi 12T Pro / Redmi K50 Ultra (diting)
Maintainer:@TeamMEX_XDA (Kισżż)
Version:Bliss-v18.1-diting-UNOFFICIAL-gapps-20250109
Download
Firmware
Device Changelog:
- Add Updater support
- Yuki kernel updated
- Enable smartpixels and disable it on udfps location
- enable Screen off udfps support
- use correct sensor for pocket mode
- initial release for diting
'#BlissRom' '#Voyager' '#Bliss18.1'
If you like my work and want to support it please consider making a donation this helps with server costs.
Donate PayPal
Follow @xiaomi_12tpro_updates
Join @xiaomi12tpro_chat
🪐 In 1977, the Voyager 2 spacecraft was launched carrying a special message for any potential alien civilizations—a Golden Record encoded with music, greetings in 55 languages, and sounds from Earth. Voyager 2 is now over 20 billion kilometers from our planet, traveling beyond the edge of the solar system and continuing its silent journey through interstellar space. ✨
#aliens⚡#voyager⚡#interstellar⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 In 1977, the Voyager 1 spacecraft left Earth carrying a "Golden Record"—a carefully crafted message with sounds and images from our planet, designed in the hope that someday it might be found by aliens in another star system. Now Voyager 1 is more than 24 billion kilometers away, continuing its silent journey through interstellar space, making it humanity’s most distant attempt to reach out to any extraterrestrial civilization. ✨
#aliens⚡#voyager⚡#interstellar⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 In 1977, the Voyager 1 spacecraft carried a "Golden Record" with sounds and images from Earth—including greetings in 55 languages, music from around the world, and natural sounds like thunder and whale songs. This unique message is still traveling through interstellar space beyond our solar system, intended for any alien civilization that might one day discover the spacecraft drifting among the stars. ✨
#aliens⚡#Voyager⚡#record⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
🪐 The future of interstellar travel could be shaped by experiments like NASA's Heliospheric Imager, which studies the vast region where the Sun's solar wind meets interstellar space—the heliopause. By understanding this distant boundary zone, where Voyager 1 crossed over 120 astronomical units from the Sun, scientists are learning how future spacecraft might navigate safely beyond our solar system and toward other stars like Alpha Centauri. ✨
#interstellar⚡#heliopause⚡#voyager⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels
🪐 The twin Voyager spacecraft—Voyager 1 and Voyager 2—are now traveling through the region known as interstellar space, beyond the influence of our Sun's solar wind. Their ongoing journey past the heliopause, the boundary where the solar wind meets the interstellar medium (the thin gas and dust between stars), is giving scientists the first direct data on what lies between stars like our Sun and others such as Alpha Centauri. ✨
#interstellar⚡#travel⚡#voyager⚡#heliopause⚡#nasa⚡#galaxy⚡#stars⚡#astronomy⚡#universe⚡#cosmos⚡#space
👉subscribe Universe Mysteries
👉more Channels