@sgmrt · Post #1504 · 20.09.2022 г., 23:04
[NSL]: Train services has resumed. Free regular bus services between #Yishun and #ToaPayoh has ceased. - SMRT
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
Пребарај: #toapayoh
@sgmrt · Post #1504 · 20.09.2022 г., 23:04
[NSL]: Train services has resumed. Free regular bus services between #Yishun and #ToaPayoh has ceased. - SMRT
@sgmrt · Post #1503 · 20.09.2022 г., 22:49
[NSL] UPDATE: Due to a track fault, pls add 15mins train travel time btwn #Yishun and #ToaPayoh. Free regular bus svcs from #Yishun to #ToaPayoh. - SMRT
@sgmrt · Post #1501 · 20.09.2022 г., 22:23
[NSL]: Due to a track fault, pls add 15mins train travel time btwn #Yishun and #ToaPayoh. Free regular bus svcs from #Yishun to #ToaPayoh. Our station staff will assist. - SMRT
@sgmrt · Post #1500 · 20.09.2022 г., 22:07
[NSL]: Due to a track fault, pls add 15mins train travel time btwn #Yishun and #ToaPayoh. - SMRT
@sgmrt · Post #2386 · 08.07.2025 г., 01:54
[NSL] UPDATE: Track fault cleared, train services are progressively being restored. Please add 10mins train travel time from #ToaPayoh to #Somerset. - SMRT
@sgmrt · Post #2318 · 16.04.2025 г., 04:29
[NSL]: Due to a track fault, please add 15mins travel time from #ToaPayoh to #Bishan towards #JurongEast. Free regular buses are available between #ToaPayoh and #Bishan. - SMRT
Hashtags
@sgmrt · Post #2317 · 16.04.2025 г., 04:14
[NSL]: Due to a track fault, please add 15mins train travel time from #ToaPayoh to #Bishan towards #JurongEast. Free regular buses are available between #ToaPayoh and #Bishan. Please look out for fellow commuters with special needs and lend a helping hand. We are sorry for - SMRT
Hashtags
@sgmrt · Post #2316 · 16.04.2025 г., 04:05
[NSL]: Due to a track fault, please add 15mins train travel time from #ToaPayoh to #Bishan towards #JurongEast. Free regular bus is available between #ToaPayoh and #Bishan. (Refer to Diagram 1) https://bit.ly/3YBCjlJ - SMRT
Hashtags
@sgmrt · Post #2314 · 16.04.2025 г., 03:29
[NSL]: Due to a track fault, pls add 15mins train travel time from #ToaPayoh to #Bishan towards #JurongEast. Free regular bus is available between #ToaPayoh and #Bishan. - SMRT
Hashtags
@sgmrt · Post #2226 · 10.01.2025 г., 10:44
[NSL] CLEARED: Fault cleared, train service between #MarinaSouthPier and #Bishan has resumed. Free regular bus svc btwn #MarinaSouthPier and #ToaPayoh has ceased. - SMRT
Hashtags
@sgmrt · Post #2225 · 10.01.2025 г., 10:39
[NSL] UPDATE: Train service between #MarinaSouthPier and #Bishan has resumed. Free regular bus svc btwn #MarinaSouthPier and #ToaPayoh has ceased. Trains are running normally. - SMRT
Hashtags
@sgmrt · Post #2224 · 10.01.2025 г., 10:34
[NSL] UPDATE: Train service between #MarinaSouthPier and #Bishan has resumed. Free regular bus svc btwn #MarinaSouthPier and #ToaPayoh is still available. - SMRT
Hashtags