Skip to content

AI junk - #6124

Closed
rowkav09 wants to merge 1 commit into
pallets:mainfrom
rowkav09:fix/stream-context-abandonment
Closed

AI junk#6124
rowkav09 wants to merge 1 commit into
pallets:mainfrom
rowkav09:fix/stream-context-abandonment

Conversation

@rowkav09

@rowkav09 rowkav09 commented Aug 8, 2026

Copy link
Copy Markdown

What changed

stream_with_context now pushes the captured context only while advancing or closing the wrapped iterator. This prevents an abandoned stream finalized on another thread from leaving the worker thread with a stale application context.

Added a regression test covering a cross-thread stream finalization and a subsequent request on the same worker.

Testing

  • uv run --project C:/oss-flask pytest C:/oss-flask/tests -q (492 passed)
  • Ruff check and format check passed

Fixes #6123

@davidism davidism closed this Aug 8, 2026
@davidism

davidism commented Aug 8, 2026

Copy link
Copy Markdown
Member

Besides being AI generated, which is against our policy, this introduces extreme inefficiency due to pushing and popping the context on every loop.

@davidism davidism changed the title Fix stream context cleanup across threads AI junk Aug 11, 2026
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.

stream_with_context: abandoned generator leaves the app context current on the worker thread; later requests skip teardown_appcontext

2 participants