aio-libs / aio-libs/aiohttp

Changing readers to async iterators

Open
#5,911 0 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
16.5k
Forks
2.4k
Avg merge
17h 22m
Merged PRs (30d)
212

Description

### Is your feature request related to a problem?

Not problem, but looks legacy

```
while True:
chunk = await field.read_chunk()
if not chunk:
break
```

or

```
reader = await request.multipart()
while True:
field = await reader.next()
if field is None: break
```

### Describe the solution you'd like

```
async for chunk in field.chunks():
f.write(chunk)
```

or

```
async for field in (await request.multipart()):
....
```

### Describe alternatives you've considered

Or fix docs on objects already has __anext__ interface.

### Related component

Server

### Additional context

_No response_

### Code of Conduct

- [X] I agree to follow the aio-libs Code of Conduct

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.