Отдельно разберём 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
Harbor
Decentralized p2p identity verification system.
Identity management application written, targeting iOS, and Android, built on Polycentric. Create pseudonymous identities, make claims, link identities across applications.
Checkout harbor.social, or docs.polycentric.io for more information
What is Harbor and How it Works:
https://peertube.futo.org/w/939a212d-920f-4411-b9b6-d60aa4ef4db7
https://gitlab.futo.org/polycentric/harbor/
#p2p#id#verification#futo
https://x.com/HappyShaunVT/status/2026711290039906367
HappyShaun : Face verification is getting interesting. I THINK I CAN TRUST IT.
#happyshaun#vrchat#verification#meme#trust#lime
#Systemd Adds #Age#Verification & #Reddit#Linux Censors Age Verification Posts
Plus: Which Open Source Operating Systems plan to include Age Verification? The Lunduke Journal compiles a list.
Does It Age Verify?:
https://github.com/BryanLunduke/DoesItAgeVerify
https://lunduke.com
https://www.youtube.com/watch?v=M3erhbwqIAM
Lennart Poettering
#microsoft#stalking#surveillance#backdoor#trojan
Fight Disinformation with AI
INAR .IA Labs & Technologies has raised $1.21M for its innovative SaaS platform aimed at automating the detection and verification of disinformation across online content. Scheduled to launch on December 18, 2024, this multimodal and multilingual tool is set to enhance online security and information integrity. More details can be found at TrueFlag.
#Funding#Technology#AI#SaaS#Disinformation#Verification#OnlineSafety#Security#Innovation#Automation#Multimodal#Multilingual#Integrity#Content#Platform#Launch #2024 #INAR#TrueFlag#Labs