pallets / pallets/quart

`stream_with_context` does not propagate `g`

Open
#361 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.7k
Forks
206
PR merge metrics
No merged PRs in 30d

Description

When I use the stream_with_context decorator on a streaming generator, attributes set on the g object earlier in the request aren't visible in the generator. Someone else has described this already on stackoverflow and given an example.

This is easily worked around by passing the needed attributes into the generator and restoring them when it starts, but it's a surprising behavior that should be either changed or documented.

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 at the stream_with_context decorator and reproduce the behavior using the linked Stack Overflow example, checking how request context and g are handled by the streaming generator. Resolve whether the expected outcome is propagation or documentation, then verify the chosen behavior with regression coverage or updated documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.