小编Ali*_*szn的帖子

RuntimeError:刷新请求时 FastAPI 中没有返回响应

我在我的应用程序中遇到此错误,但我不知道为什么。经过多次搜索和调试后发现,当我在获得响应之前刷新请求时(取消请求并在处理上一个请求时发送另一个请求),就会发生这种情况。由于我的应用程序需要超过 2 秒的时间来响应,因此我遇到了太多此类错误。

到目前为止,我从我的中间件中知道了它,但我不知道为什么会发生这种情况以及我应该做什么。

知道如何解决这个问题吗?

这是我得到的错误:

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/anyio/streams/memory.py", line 81, in receive
    return self.receive_nowait()
  File "/usr/local/lib/python3.9/site-packages/anyio/streams/memory.py", line 76, in receive_nowait
    raise WouldBlock
anyio.WouldBlock

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/starlette/middleware/base.py", line 35, in call_next
    message = await recv_stream.receive()
  File "/usr/local/lib/python3.9/site-packages/anyio/streams/memory.py", line 101, in receive
    raise EndOfStream
anyio.EndOfStream

During handling of the above exception, another exception occurred:

Traceback (most recent call last): …
Run Code Online (Sandbox Code Playgroud)

python starlette fastapi

25
推荐指数
1
解决办法
2万
查看次数

标签 统计

fastapi ×1

python ×1

starlette ×1