From: Sebastián Ramírez Date: Tue, 10 Feb 2026 11:36:53 +0000 (-0800) Subject: ♻️ Simplify reading files in memory, do it sequentially instead of (fake) parallel... X-Git-Tag: 0.128.7~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25270fcee0c71c3bc661e40501fa3838beb6d99b;p=thirdparty%2Ffastapi%2Ffastapi.git ♻️ Simplify reading files in memory, do it sequentially instead of (fake) parallel (#14884) --- diff --git a/fastapi/dependencies/utils.py b/fastapi/dependencies/utils.py index 80f9c76e9..23d8cd9fb 100644 --- a/fastapi/dependencies/utils.py +++ b/fastapi/dependencies/utils.py @@ -1,7 +1,7 @@ import dataclasses import inspect import sys -from collections.abc import Coroutine, Mapping, Sequence +from collections.abc import Mapping, Sequence from contextlib import AsyncExitStack, contextmanager from copy import copy, deepcopy from dataclasses import dataclass @@ -15,7 +15,6 @@ from typing import ( cast, ) -import anyio from fastapi import params from fastapi._compat import ( ModelField, @@ -903,16 +902,8 @@ async def _extract_form_body( # For types assert isinstance(value, sequence_types) results: list[Union[bytes, str]] = [] - - async def process_fn( - fn: Callable[[], Coroutine[Any, Any, Any]], - ) -> None: - result = await fn() - results.append(result) # noqa: B023 - - async with anyio.create_task_group() as tg: - for sub_value in value: - tg.start_soon(process_fn, sub_value.read) + for sub_value in value: + results.append(await sub_value.read()) value = serialize_sequence_value(field=field, value=results) if value is not None: values[get_validation_alias(field)] = value