python-asynciofastapi 在FastAPI中,run_in_executor两者run_in_threadpool都可以让函数在其他线程中运行,并且似乎具有相同的行为。 但这有什么区别呢?使用 FastAPI 的最佳选择是什么? 演示: importasyncioimporttimefromfastapiimportFastAPIfromfastapi.concurrencyimportrun_in_threadpool app = FastAPI()@app.get("/")...
:) Thanks for sketching that out. I would have placed Event Loop directly under Uvicorn/FastAPI but you clearly know this better. Actually, pardon me if I got something wrong, as I don't know this stuff by heart: In short, if I understand right,asyncio.to_thread()is nice, a more "...