@QuietWorld · Post #7006 · 30.11.2019 г., 10:15
“The wisdom of life consists in the elimination of non-essentials.” 🍃 Lin Yu Tang #wisdom#life#simplicity @quietworld🍃
Hashtags
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
Пребарај: #simplicity
@QuietWorld · Post #7006 · 30.11.2019 г., 10:15
“The wisdom of life consists in the elimination of non-essentials.” 🍃 Lin Yu Tang #wisdom#life#simplicity @quietworld🍃
Hashtags
@QuietWorld · Post #7238 · 29.03.2020 г., 08:12
In a world that is so busy and craves a lot of attention, I'm just here to remind myself of something that I agree with; “simplicity is the essence of happiness”. A Simple Yet Rewarding Life Life is simple. The wisdom of life consists in the elimination of non-essentials. Fewer possessions = more time to spend enjoying life; because we are not worrying about how to pay for our possessions. Sure it is exciting to buy & bring home lots of stuffs like the latest electronic gadget but after a while, the excitement wears off anyway 🤷🏻♀ & here's a reminder in case we forgot; our self-worth is not measured by the material thing we possess. In fact, possessions often end up weighing us down – with them, come responsibility, guilt and stress. For example; your expensive car eats large chunk of your salary from the monthly instalments, insurance, services and road tax as well as the gas and repairment fees (if any)! You must hold on to your job to maintain your car as if you are a slave to it. “The things that we own, end up owning us.” The feeling of guilt comes when you feel that you have overpaid for something or should not have bought it in the first place. For example; tread mill or any other exercise machine 🙍🏻♀ Needless to say, stress will come from paying high price for it & worrying about losing them; either by them being broken or stolen. What more is needed to say? Simpler life = doing much with less. 😊 #simplicity#life#minimalism#minimalist#happiness @quietworld🍃
@lunaeverly · Post #73 · 05.02.2026 г., 08:28
A mini picnic in the park. 🧺 Just being here and now is the best plan for the day. Мини-пикник в парке. 🧺 Просто быть здесь и сейчас — лучший план на день. #LunaEverly#Picnic#DayMindset#Park#Simplicity