micropython / micropython/micropython-lib

requests: stream parameter is noop

Open
#777 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2.9k
Forks
1.1k
Avg merge
7d 6h
Merged PRs (30d)
3

Description

MicroPython v1.21.0; Raspberry Pi Pico W with RP2040.

requests.request exposes a stream=None parameter:

https://github.com/micropython/micropython-lib/blob/d8e163bb5f3ef45e71e145c27bc4f207beaad70f/python-ecosys/requests/requests/__init__.py#L36-L46

but it is never functionally used, nor is some iter_content API exposed; the parameter is only forwarded to recursive request calls.

Workaround:

r = requests.get(...)
# sidestep @property content, which just reads socket data into memory until EOF
s = r.raw
r.raw = None
buf = bytearray(1024)
while s.readinto(buf) > 0:
    # handle data in buf (e.g. write to file)

if the above is implemented into some iter_content, is the stream parameter even needed? Am I missing something?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in python-ecosys/requests/requests/init.py at the request function linked in the issue, then trace how stream is forwarded and how response.content and response.raw consume the socket. Reproduce the current behavior on the stated MicroPython and Raspberry Pi Pico W setup; done means the intended streaming behavior is established and stream or its replacement has a consistent, usable API.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.