Skip to content

fix: Make wsgi streaming response handlers async - #191

Open
hoodmane wants to merge 2 commits into
cloudflare:mainfrom
hoodmane:hoodmane/wsgi-streaming-stack-switching
Open

fix: Make wsgi streaming response handlers async#191
hoodmane wants to merge 2 commits into
cloudflare:mainfrom
hoodmane:hoodmane/wsgi-streaming-stack-switching

Conversation

@hoodmane

@hoodmane hoodmane commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

So it's possible to stack switch inside of them. Also, make sure that contextvars are preserved.

On top of #189.

@hoodmane
hoodmane force-pushed the hoodmane/wsgi-streaming-stack-switching branch from a6244ea to b3d02b4 Compare August 7, 2026 20:03
So it's possible to stack switch inside of them. Also handle contextvars
@hoodmane
hoodmane force-pushed the hoodmane/wsgi-streaming-stack-switching branch from b3d02b4 to 53e2f5e Compare August 7, 2026 20:04

@ryanking13 ryanking13 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.

Looks good to me. I left one question.

async def pull(controller: Any) -> None:
try:
chunk = next(chunks, _END)
chunk = ctx.run(next, chunks, _END)

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.

So if we don't set this the contextvars can be leaked between requests? Does this only apply to the streaming response?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants