Browse Source

Continue patch from #5122 by not limiting response model validation

pull/12066/head
Noah Klein 7 months ago
parent
commit
3c29f0f97c
  1. 10
      fastapi/routing.py

10
fastapi/routing.py

@ -20,6 +20,9 @@ from typing import (
Type,
Union,
)
import anyio
from anyio import CapacityLimiter
import functools
from fastapi import params
from fastapi._compat import (
@ -163,9 +166,10 @@ async def serialize_response(
if is_coroutine:
value, errors_ = field.validate(response_content, {}, loc=("response",))
else:
value, errors_ = await run_in_threadpool(
field.validate, response_content, {}, loc=("response",)
)
# Run without a capacity limit for similar reasons as marked in fastapi/concurrency.py
exit_limiter = CapacityLimiter(1)
validate_func = functools.partial(field.validate, loc=("response",))
value, errors_ = await anyio.to_thread.run_sync(validate_func, response_content, {}, limiter=exit_limiter)
if isinstance(errors_, list):
errors.extend(errors_)
elif errors_:

Loading…
Cancel
Save