Отдельно разберём 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
🇨🇳 La Chine a procédé au lancement réussi du satellite expérimental Shiyan‑33 qui sera principalement utilisé pour l’étude de l’environnement spatial, a rapporté l’agence Xinhua.
#chine#satellite#lancement
🌍 In 1972, the first Landsat satellite began photographing Earth's surface from space, fueling a new era of digital mapping and revealing real-time changes in forests, cities, and coastlines. ✨
#cartography⚡#satellite⚡#mapping⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 The deepest parts of the Amazon rainforest were first mapped by satellite only in the 21st century. Modern exploration now reveals hidden rivers and lost cities from space in this vast green wilderness. ✨
#exploration⚡#rainforest⚡#satellite⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography🌍
🌍 Space-based radar now tracks land subsiding from groundwater loss, revealing areas sinking by centimeters each year. These invisible changes help pinpoint regions at risk of flooding and damage. ✨
#remote⚡#sensing⚡#satellite⚡#geography⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
https://github.com/daleroberts/tv
tv ("#textview") is a small tool to quickly view high-resolution multi-band imagery directly in your terminal. It was designed for working with (very large) #satellite imagery data over a low-bandwidth connection. For example, you can directly visualise a Himawari 8 (11K x 11K pixel) image of the Earth directly from its URL:
It is built upon the wonderful #GDAL library so it is able to load a large variety of image formats (GeoTiff, PNG, Jpeg, NetCDF, ...) and subsample the image as it reads from disk so it can handle very large files quickly. It has the ability to read filenames (or URLs) from stdin and load files directly from URLs without writing locally to disk. Command line options are styled after gdal_translate such as:
-b to specify the bands (and ordering) to use,
-srcwin xoff yoff xsize ysize to view a subset of the image,
-r to specify the subsampling algorithm (nearest, bilinear, cubic, cubicspline, lanczos, average, mode).
$450K Fundraise for Bifrost Connect
OrbitalNerds has raised $450K for its innovative satellite SSH service, Bifrost Connect, on December 4, 2024. For more details, visit OrbitalNerds.
#Funding#Satellite#SSH#BifrostConnect#OrbitalNerds
Myriota Secures $50M Funding
Myriota has successfully raised $50 million in funding for its direct-to-orbit satellite connectivity solutions aimed at the Internet of Things. This funding round took place on December 19, 2024. For more details, visit Myriota.
#Myriota#Funding#Satellite#IoT#Connectivity#SpaceTech#DirectToOrbit#Investment#TechNews#Telecommunications