Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках.
Выглядело это примерно так:
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
Android Tool
Program to manage control Android devices with Fastboot and ADB
Main Features:
Batch and single app installation (.apk files)
Disable, enable or uninstall system apps
Open, force stop or clear data of your apps
Receive and save logs from your device
Install or boot custom recovery or wipe partitions
Save apps list
Always relevant links to firmware and everything you need
And more
https://github.com/fast-geek/Android-Tool
Download - https://github.com/fast-geek/Android-Tool/releases
Telegram channel - @android_tooI
Telegram chat - @android_tooI_chat
4PDA thread - https://4pda.to/forum/index.php?showtopic=1000362
📡@NoGoolag📡@Libreware
#adb#fastboot
How to run #ADB and #fastboot in #Termux without root to unlock #bootloader, run ADB commands, remove #bloatware, flash ROM, or even root another #Android
https://www.mobile-hacker.com/2025/06/16/how-to-run-adb-and-fastboot-on-a-non-rooted-android-smartphone-using-termux/:
1. It supports debloating of various manufacturers and mobile carriers such as LG, Samsung, Xiaomi, Huawei, Oppo, Realme, Vivo, ZTE, OnePlus, Nokia, Sony, Asus, Google, Fairphone, Motorola, Tecno, Unihertz.
2. Full access to the app’s private storage — including databases, tokens, cached credentials, config files, or even offline user data.
3. Another common issue in AndroidManifest.xml is this flag: When enabled (which it is by default unless explicitly disabled), Android allows the app’s private data to be backed up via ADB — again, even on non-rooted devices.
Android, use termux-adb command instead of adb
https://github.com/nohajc/termux-adb
Android debloater for pc and debloat lists
https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation
https://github.com/Universal-Debloater-Alliance/universal-android-debloater-next-generation/blob/main/resources/assets/uad_lists.json
#debloat