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

Резултати

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

Пребарај: #curry

当前筛选 #curry清除筛选
Todo sobre cocteleria🥃🍹🍸

@todococktail · Post #404 · 26.08.2021 г., 00:10

Swizzle Stick : @bartender_adriel El Swizzle Stick es una herramienta de #bar , muy utilizada fundamentalmente en la elaboración de #cócteles#Tiki . Es hecha originalmente a partir de las ramas de una especie de árbol llamado " Quararibea Turbinate ", las cuales desprenden un aroma especiado parecido al #curry. Este utensilio se utilizaba en la cocina de las indias occidentales , para elaborar alimentos como salsas o pastas y hacerlos oxigenar antes de la cocción , luego fue llevado a las barras, donde ha perdurado por su elegancia y funcionalidad . En la actualidad los swizzle stick se elaboran de diferentes materiales , como metal , plástico , goma o policarbonato , pero los tradicionales son los fabricados a partir de las ramas de la Quararibea. Esta herramienta logra una dilución controlada y genera frío muy intenso .

🍛Two Iconic South African Curries 🇿🇦 Two of the most famous curries in South African cuisine represent the two port cities — Cape Town on the west coast and Durban on the east. ⚓️ Even their names reflect their origins: 🌶Cape Malay Curry Powder refers to Cape Town’s Malay community, 🔥Durban Curry Masala — to Durban’s Indian community. The Cape curry is slightly sweeter and milder, while the Durban curry is hotter and more vibrant thanks to the addition of Kashmiri red chili. 🌶 Source: https://t.me/africamother/800 #SouthAfrica#Food#Cuisine#Cooking#CapeTown#Durban#Spices#Curry