Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках.
Выглядело это примерно так:
from fastapi.concurrency import run_in_threadpool
async def execute(data: DataRequest) -> DataResponse:
try:
result = await run_in_threadpool(sync_function, data)
return DataResponse(data=result)
except Exception as e:
return DataResponse(
error=str(e),
success=False,
)
В общем работает нормально. Для всех вызовов под капотом используется общий тредпул, всё работает предсказуемо.
Но потребовалось изменить количество запускаемых в пуле потоков (по умолчанию создается 40 воркеров).
Так как дело происходит с FastAPI, делается это через lifespan используя настройки anyio:
import anyio
@asynccontextmanager
async def lifespan(app: FastAPI):
limiter = anyio.to_thread.current_default_thread_limiter()
limiter.total_tokens = 100
yield
# если вдруг нужно вернуть обратно
limiter.total_tokens = 40
Зачем менять количество воркеров?
- уменьшить, если оперативки мало (один тред занимает ~8мб)
- увеличить чтобы выдержать нагрузку
Если есть предложения получше при тех же вводных - предлагайте😉
#async
Любимые Velvetyne представили подсайт с дружественными open source шрифтовыми студиями
О многих из них я писал в рамках #oss, но нового там тоже достаточно.
Очень воодушевляет их подход к распространению, что они именуют как «libre typography».
«At Velvetyne, we’re all about promoting a more ethical approach to libre typography. We believe in respecting creators’ consent and celebrating the diverse range of voices in this creative space. We’re aware of the historical importance of our catalogue and our visibility, but we’re definitely not looking to monopolise anything».
Почитать, посмотреть, скачать
K-k开k罗l谍d影y- OSS117之开罗谍影 OSS 117: Le Caire, nid d'espions (2006)
直达链接:https://pan.quark.cn/s/48fdf8c2c548
#OSS117之开罗谍影#法国特工117
#OSS 117: Le Caire, nid d'espions
#OSS 117: Cairo, Nest of Spies
链接:https://link3.cc/sf_com
#电影#喜剧#欧洲#00年代
#ParanoidAndroid#Unofficial#ROM#OSS#U#diting
AOSPA - Uvite¹⁴ Beta 1 | Android 14
Updated : 27/01/2024
▪️Download ROM | TWRP
Notes:
- Initial Build
- Selinux Enforcing
- MiuiCamera included
- Flash latest HyperOS firmware depending on your region.
Instructions:
- Reboot to bootloader
- Flash either the provided TWRP or aospa recovery.img from sf depending on your needs
- Reboot to recovery and sideload the ROM zip
- Reboot to TWRP and install HyperOS firmware
- Format Data
- Reboot to system
Bugs? You tell me...
By: @Megalodonzs | Donate
Support: Join
#typescript#ai#nocode#oss#synthetic_data
Hugging Face AI Sheets is a free, no-code tool that lets you create, improve, and change datasets easily using AI models through a spreadsheet-like interface. You can start with your own data or generate new data by writing simple prompts. It supports thousands of open AI models and works locally or online. You can clean data, classify text, add missing info, or create synthetic data without coding. It also lets you compare different AI models and improve results by editing outputs. This tool helps you save time and effort in managing data and testing AI models quickly and flexibly.
https://github.com/huggingface/aisheets
#java#docker#mybatis#oss#springboot#vue
RuoYi-Vue-Plus is a free, open-source backend framework upgraded from RuoYi for distributed clusters and multi-tenant use, built with Spring Boot 3.5, Vue3, TypeScript, MyBatis-Plus, and Redisson. It offers superior features like plugin decoupling, advanced permissions, multi-database support, workflows, code generation, Docker deployment, monitoring, and data security tools—far beyond original RuoYi. You benefit by building scalable enterprise apps 80% faster with less code, easier maintenance, and robust security for production. Warning: Versions ≤5.5.3 have critical flaws (CVE-2025-66916 RCE, CVE-2026-2819 auth bypass); update immediately.
https://github.com/dromara/RuoYi-Vue-Plus
#rust#bigdata#cloud_native#distributed_systems#filesystem#minio#object_storage#oss#rust#s3
RustFS is a fast and safe distributed object storage system built with Rust, offering high performance and scalability for large data needs like AI and big data. It is compatible with S3, easy to use, and open source under the business-friendly Apache 2.0 license. Compared to others like MinIO, RustFS provides better memory safety, no risky data logging, and supports local cloud providers. You can quickly install it via a script or Docker, manage storage through a simple web console, and benefit from a strong community and detailed documentation. This makes RustFS a reliable, cost-effective choice for secure, scalable storage.
https://github.com/rustfs/rustfs