[RFC]: Lazy state changes.
維護者通常 4 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 25/100
- Issue 類型
- 功能
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- python
研究方向
從文件化的 H2Connection.receive_data API 和 issue 的事件序列開始;將其目前回傳列表的契約與提議的 lazy generator 行為進行比較。完成意味著就是否接受 breaking API change 達成專案決策,並記錄由此產生的方向;issue 中未指定任何實作檔案或測試。
由索引模型根據 Issue 內容生成。
描述
Inspired by @njsmith in njsmith/h11#4.
Right now there is a wart in the h2 API when working on a busy connection. The problem exists when working with receive_data. For example, it is possible that you might encounter the following set of events returned from receive_data: [DataReceived(stream_id=1), WindowUpdated(stream_id=1), StreamReset(stream_id=1)].
In response to that WindowUpdated you may want to send another data frame on stream 1, but if you do so without processing the entire event list h2 will throw a ProtocolError at you because the stream is now in the CLOSED state. However, the user doesn't know that: they're processing the events serially, and haven't gotten to the event that actually closed the stream.
The outcome of this is not too bad: while the ProtocolError does get thrown, the connection state is still fine and no damage has been done to your ability to continue to use the connection. However, the exception may cause an incautious user to run into trouble: if they're not expecting and handling this exception it'll quite probably cause them to lose a lot of application state.
In njsmith/h11#4, @njsmith has proposed a split API for receiving data: a single receive_data call returns no events, but instead you need to call next_event to advance the state machine. This proposal is essentially a "split" API much like we have for sending.
Making that change is a pretty substantial API change and I don't know how I feel about it. However, it turns out that hyper-h2 is capable of emulating that change with a very simple change to the logic of receive_data.
Right now, receive_data returns a list of events. However, it would be a trivial change for receive_data to return a generator instead. That generator would then iterate across events, one event at a time. The effect of doing that would be to avoid updating the state machines until the user has an event in hand, and would essentially immediately change hyper-h2 to an API that lazily updates stream state. This would ensure that a user cannot see a ProtocolError for sending data on a closed stream unless they have iterated past an event that closed the stream (or they closed it themselves).
I'm interested in what @python-hyper/contributors think, as well as our wider user-base. I think making such a change would be extremely valuable, but it represents a breaking API change (receive_data is documented as returning a list).
Do people think this change is sensible?
- 主要語言
- Python
- 星號
- 1k
- 分支
- 197
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python-hyper/h2 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 45/100
python-hyper/h2#1330 ·
維護者通常 4 天內回覆
-
content-length is not policed when a stream ends with a trailers section可能已有人在做 @feiiiiii5 於 30 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 76/100
python-hyper/h2#1328 ·
維護者通常 4 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
python-hyper/h2#1312 ·
維護者通常 4 天內回覆
-
難度 4/5 3-5 天 新手友好度 35/100
python-hyper/h2#1280 · 2 則留言 ·
維護者通常 4 天內回覆
-
難度 3/5 1-2 天 新手友好度 45/100
python-hyper/h2#1239 · 3 個 reaction ·
維護者通常 4 天內回覆
相似的 Issue
-
The changelog workflow excludes otelbot but not dependabot, so every Dependabot pull request fails the changelog check可能已有人在做 @ocelotl 今天認領。 未關閉
難度 1/5 1 小時以內 新手友好度 82/100
open-telemetry/opentelemetry-python#5825 ·
維護者通常 2 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
cuga-project/cuga-agent#1020 ·
維護者通常 2 天內回覆
-
難度 1/5 1 小時以內 新手友好度 70/100
microsoft/playwright#43640 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 84/100
stac-utils/stac-fastapi-elasticsearch-opensearch#965 ·
維護者通常 2 天內回覆
-
from-review-extraction library privacy python severity:suggested
難度 2/5 1-3 小時 新手友好度 83/100
LearningCircuit/local-deep-research#7951 ·
維護者通常 2 天內回覆