@QuietWorld · Post #6726 · 17.10.2019 г., 13:01
It's often just enough to be with someone. I don't need to touch them. Not even talk. A feeling passes between you both. You're not alone. – Marilyn Monroe #solitude@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
Пребарај: #solitude
@QuietWorld · Post #6726 · 17.10.2019 г., 13:01
It's often just enough to be with someone. I don't need to touch them. Not even talk. A feeling passes between you both. You're not alone. – Marilyn Monroe #solitude@quietworld🍃
Hashtags
@QuietWorld · Post #6722 · 16.10.2019 г., 23:30
I have to be alone very often. I'd be quite happy if I spent from Saturday night until Monday morning alone in my apartment. That's how I refuel. – Audrey Hepburn #solitude@quietworld🍃
Hashtags
@QuietWorld · Post #6714 · 15.10.2019 г., 08:30
A man can be himself only so long as he is alone. – Arthur Schopenhauer #solitude @quietworld🍃
Hashtags
@QuietWorld · Post #6705 · 14.10.2019 г., 08:30
If you make friends with yourself you will never be alone. – Maxwell Maltz #solitude#quotes @quietworld🍃
@QuietWorld · Post #6701 · 13.10.2019 г., 23:30
Alone let him constantly meditate in solitude on that which is salutary for his soul, for he who meditates in solitude attains supreme bliss. – Guru Nanak #solitude#quotes @quietworld🍃
@QuietWorld · Post #6700 · 13.10.2019 г., 13:00
"There's a tremendous difference between alone and lonely. You could be lonely in a group of people. I like being alone. I like eating by myself. I go home at night and just watch a movie or hang out with my dog. I have to exert myself and really say, oh God, I've got to see my friends 'cause I'm too content being by myself." - Drew Barrymore - #quotes#solitude @quietworld🍃
@QuietWorld · Post #6673 · 09.10.2019 г., 12:00
We visit others as a matter of social obligation. How long has it been since we have visited ourselves? #solitude#quotes @quietworld🍃
@QuietWorld · Post #6670 · 09.10.2019 г., 00:00
Solitude is a good place to visit but a poor place to stay. —Josh Billings – #solitude#quotes @quietworld🍃
@QuietWorld · Post #6668 · 08.10.2019 г., 12:00
When we cannot bear to be alone, it means we do not properly value the only companion we will have from birth to death — ourselves. – Morris Adler – #solitude#quotes @quietworld🍃
@QuietWorld · Post #6662 · 08.10.2019 г., 05:00
There's one thing worse than being alone – wishing you were. #solitude#quotes @quietworld🍃
@QuietWorld · Post #6688 · 11.10.2019 г., 08:30
Men go abroad to wonder at the heights of mountains, at the huge waves of the sea, at the long courses of the rivers, at the vast compass of the ocean, at the circular motions of the stars; and they pass by themselves.., without wondering. – St. Augustine – #solitude#quotes#reflection @quietworld🍃
Hashtags
@QuietWorld · Post #6654 · 07.10.2019 г., 04:39
You have to start knowing yourself so well that you begin to know other people – a piece of us is in every person we can ever meet. —John D. MacDonald – #quotes#solitude#reflection @quietworld🍃
Hashtags