Skip to content

Commit 25270fc

Browse files
authored
♻️ Simplify reading files in memory, do it sequentially instead of (fake) parallel (fastapi#14884)
1 parent 8bdb0d2 commit 25270fc

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

fastapi/dependencies/utils.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import dataclasses
22
import inspect
33
import sys
4-
from collections.abc import Coroutine, Mapping, Sequence
4+
from collections.abc import Mapping, Sequence
55
from contextlib import AsyncExitStack, contextmanager
66
from copy import copy, deepcopy
77
from dataclasses import dataclass
@@ -15,7 +15,6 @@
1515
cast,
1616
)
1717

18-
import anyio
1918
from fastapi import params
2019
from fastapi._compat import (
2120
ModelField,
@@ -903,16 +902,8 @@ async def _extract_form_body(
903902
# For types
904903
assert isinstance(value, sequence_types)
905904
results: list[Union[bytes, str]] = []
906-
907-
async def process_fn(
908-
fn: Callable[[], Coroutine[Any, Any, Any]],
909-
) -> None:
910-
result = await fn()
911-
results.append(result) # noqa: B023
912-
913-
async with anyio.create_task_group() as tg:
914-
for sub_value in value:
915-
tg.start_soon(process_fn, sub_value.read)
905+
for sub_value in value:
906+
results.append(await sub_value.read())
916907
value = serialize_sequence_value(field=field, value=results)
917908
if value is not None:
918909
values[get_validation_alias(field)] = value

0 commit comments

Comments
 (0)