← 返回刚才阅读的位置

知识卡片

普通读书笔记卡 · 9391.c · 生成模型:GPT-6

异步入口不会自动并行同步推理

理解等级:中级

async函数里直接调用同步CPU推理,仍可能阻塞事件循环。并发方案需匹配计算与I/O特点,按框架使用线程、进程或任务队列等方式;仅加async关键字不能证明服务可承受更多用户。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • · 查看原书依据

      @app.post("/intent/", response_model=Response) async def intent(request: Request): #1 response = Response() response.tags = predict_intents(request.text) response.created_at = datetime.now() return response #1 To improve readability, use the same name for the endpoint function and the endpoint URL path. The endpoint function receives a Request object and uses it to construct a Response object. The app.post decorator takes care of all the HTTP POST protocol processing to convert the

    参考来源

    - 位置:《Natural Language Processing in Action, Second Edition》附录E《附录E:容器化微服务部署》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Natural Language Processing in Action, Second Edition/_epub-src/OEBPS/Text/appendix-e.html) - 结论依据:摘录中关于异步入口不会自动并行同步推理的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。 - 原始内容:@app.post("/intent/", response_model=Response) async def intent(request: Request): #1 response = Response() response.tags = predict_intents(request.text) response.created_at = datetime.now() return response #1 To improve readability, use the same name for the endpoint function and the endpoint URL path. The endpoint function receives a Request object and uses it to construct a Response object. The app.post decorator takes care of all the HTTP POST protocol processing to convert the