Skip to content

feat(python): stream iterator request bodies - #515

Open
barjin wants to merge 3 commits into
masterfrom
feat/python-streaming-bodies
Open

feat(python): stream iterator request bodies#515
barjin wants to merge 3 commits into
masterfrom
feat/python-streaming-bodies

Conversation

@barjin

@barjin barjin commented Aug 13, 2026

Copy link
Copy Markdown
Member

Lets content= take a sync or async iterable of byte chunks and streams it into the request instead of buffering it; stacked on #514.

Related: #513

@barjin
barjin force-pushed the feat/python-streaming-bodies branch 3 times, most recently from de17fef to 0aa0f27 Compare August 14, 2026 12:35
@barjin
barjin force-pushed the feat/python-streaming-bodies branch from 0aa0f27 to bd202ad Compare August 17, 2026 07:39
@barjin
barjin force-pushed the feat/python-streaming-bodies branch from bd202ad to 2d3886e Compare August 17, 2026 07:49
@barjin
barjin force-pushed the feat/python-streaming-bodies branch from 2d3886e to 7d520db Compare August 18, 2026 08:59
Base automatically changed from feat/rust-streaming-bodies to master August 18, 2026 09:37
@barjin
barjin force-pushed the feat/python-streaming-bodies branch from 7d520db to 61e978c Compare August 18, 2026 09:37
@github-actions github-actions Bot added this to the 147th sprint - Tooling team milestone Aug 18, 2026
@github-actions github-actions Bot added t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics. labels Aug 18, 2026
barjin added 2 commits August 18, 2026 12:24
`content=` now accepts any (async) iterable of byte chunks, which is fed into
the request as the chunks are produced instead of being buffered first.

Related: #513
@barjin
barjin force-pushed the feat/python-streaming-bodies branch from 61e978c to a8f9006 Compare August 18, 2026 10:24
@barjin
barjin requested review from Mantisus and Pijukatel August 18, 2026 11:02

@Pijukatel Pijukatel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about those time.sleep(0.1) in tests. Can that get flaky? Isnt there some more robust way to do it?

Comment thread impit-python/test/basic_client_test.py Outdated
Binding the socket before starting the thread removes the startup sleep, and
the thread is joined even when an assertion fails.
def echoing_server(port_holder: list[int], body_started: threading.Event | None = None) -> None:
"""Echo the raw request (request line, headers and body) back in the response body.
@contextlib.contextmanager
def echoing_server(body_started: threading.Event | None = None) -> Iterator[int]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw. if you move all those helper server functions to a standalone non-test file, you can just import them - to avoid having duplicate echoing_server

@Mantisus Mantisus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only one moment.

#[pyo3(transparent, annotation = "dict[str, str]")]
Form(HashMap<String, String>),
#[pyo3(transparent, annotation = "Iterable[bytes] | AsyncIterable[bytes]")]
Iterator(PyIterator),

@Mantisus Mantisus Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

str is also iterable, so it matches the Iterator variant and will be processed as an iterator instead of raising an unsupported-type error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants