TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #425 · 20 апр.

Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках. Выглядело это примерно так: 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

Hashtags

Резултати

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

Пребарај: #mqtt

当前筛选 #mqtt清除筛选
Libreware

@libreware · Post #1548 · 15.02.2026 г., 11:52

Stop Trusting #Messaging Apps! Build Your Own Global #Meshtastic#MQTT Network - Explained Simply Most messaging apps promise privacy, but very few let you control the infrastructure behind your conversations. https://rumble.com/v75rxrg #im#mesh#p2p

GitHub Trends

@githubtrending · Post #15331 · 14.12.2025 г., 12:00

#c_lang#bk7231#bk7231n#bk7231t#bl602#home_assistant#iot#ln882h#mqtt#smart_home#tasmota#tuya#w600#w601#w800#w801#wifi#xr809 OpenBeken is a free Tasmota-like firmware for Tuya devices with chips like BK7231T/N, BL602, W600, ESP32, and 20+ others, adding MQTT, Home Assistant auto-discovery, OTA updates, scripting, sensors, power metering, and RGB LED control. Download ready binaries, flash easily via GUI tools or UART, and use a 700+ device database with guides. You gain cloud-free smart home control, easy local setup without AP mode, lower power use, and full customization for reliable automation. https://github.com/openshwprojects/OpenBK7231T_App

GitHub Trends

@githubtrending · Post #15204 · 08.10.2025 г., 11:30

#java#cloud#coap#dashboard#iot#iot_analytics#iot_platform#iot_solutions#java#kafka#lwm2m#microservices#middleware#mqtt#netty#platform#snmp#thingsboard#visualization#websockets#widgets ThingsBoard is an open-source IoT platform that helps manage and analyze data from connected devices. It allows users to collect data, create real-time dashboards, and automate tasks using a powerful rule engine. This platform supports various protocols like MQTT and HTTP, making it easy to connect devices. Users can also define relationships between devices and assets, and trigger alarms based on specific conditions. The benefit is that it simplifies IoT project development, making it scalable and efficient for applications like smart farming, smart offices, and more. https://github.com/thingsboard/thingsboard