Недавно делал быстрый прототип асинхронного приложения в котором требовалось вызывать много синхронного кода. Да, я знаю, что это не лучший дизайн, но нужно было быстрое решение на один процесс и без очередей. Поэтому я выполнял код в потоках.
Выглядело это примерно так:
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
#hacking#darkweb
👽
Dark Web 101 : Anonymous and Secure Browsing 2023
A guide to gaining knowledge about the Dark Web, Deep Web, Cryptocurrencies, Anonymity, and Security.
🗣Shubhang Prajapati
📆5/2023
🌐English
-----
Main channel: @repo_science
Coupons: @freecoupons_reposcience
-----
🇬🇧Dark Web #01
🇷🇺Паутина Тьмы #01
Два самых известных клона вернулись, чтобы забрать то, что принадлежит им по праву. Бен Рейли и Мэделин Прайор сыты по горло и снова разжигают АД! Человек-Паук и Люди Икс не готовы к грядущему, и пока непонятно, какую роль во всём этом играет Веном? Солнце садится, приближаются сумерки, а ночь обещает быть долгой.
#комикс#comics#паутинатьмы#darkweb
#чтиводня
#other#cti#cyberhunter#darkweb#deepweb#threat_intelligence
deepdarkCTI is a free project that collects and shares cyber threat intelligence (CTI) from the deep and dark web, helping you stay aware of hidden cyber threats like stolen data, ransomware, and hacker activities. It gathers information from places like Telegram, Discord, hacker forums, and ransomware sites to provide useful indicators and patterns of cyber attacks. You can join their Telegram group to discuss and suggest new sources or support the project with donations. Using deepdarkCTI helps you detect threats early, improve your cybersecurity decisions, and protect your organization from cyber attacks more effectively.
https://github.com/fastfire/deepdarkCTI
#python#ai_tool#darkweb#darkweb_osint#investigation_tool#llm_powered#osint#osint_tool
Robin is an AI tool that searches and scrapes the dark web, refines queries with large language models, filters results, and produces a concise investigation summary you can save or export, with Docker and CLI options and support for multiple LLMs (OpenAI, Anthropic, Gemini, local models) to fit your workflow. This helps you save hours of manual searching by automating multi-engine dark-web searches, scraping Onion sites via Tor, filtering noise with AI, and producing ready-to-use reports for faster, more focused OSINT investigations.
https://github.com/apurvsinghgautam/robin
🚀 Heart South Reports Potential Data Breach Affecting Thousands
Heart South has announced that approximately 46,666 individuals may have been affected by a data breach, with patient information from its network appearing on the dark web. According to NS3.AI, the company has been unable to verify if any specific individual's data was compromised. Notifications regarding the potential breach began being distributed in April 2026.
#HeartSouth#databreach#patientdata#darkweb#NS3AI#privacy#cybersecurity#datasecurity#breachnotification#April2026