1

我正在处理的 fastAPI 不会在请求失败时返回回溯,而是返回 500 Internal Server Error 和错误:

ERROR:    ASGI callable returned without starting response.
2021-05-14 16:12:08 - uvicorn.error:409 - ERROR - ASGI callable returned without starting response.

任何人以前遇到过这个问题并知道解决方法吗?

4

2 回答 2

0

我的问题是由自定义中间件引起的。我已经能够更新中间件并解决此问题。

于 2021-05-14T21:47:02.040 回答
0

很可能__ call __您的中间件方法效果不佳。我建议检查中间件的构建并与您的进行比较。例如:

    async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
    if scope["type"] != "http":
        await self.app(scope, receive, send)
        return

    request = Request(scope, receive=receive)
    response = await self.dispatch_func(request, self.call_next)
    await response(scope, receive, send)
于 2021-08-06T13:32:49.873 回答