[RFC]: Lazy state changes.
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Funcionalidade
- Clareza
- Precisa de esclarecimento
- Status de atividade
- Estagnada
- Stack de tecnologia
- python
- Domínio
- backend-api-design, networking
Direção de pesquisa
Comece pela API documentada H2Connection.receive_data e pela sequência de eventos da issue; compare o contrato atual, que retorna uma lista, com o comportamento proposto de lazy generator. Considera-se concluído chegar a uma decisão do projeto sobre aceitar ou não a breaking API change e registrar a direção resultante; nenhum arquivo de implementação ou teste é mencionado na issue.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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?
- Linguagem predominante
- Python
- Estrelas
- 1k
- Forks
- 197
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python-hyper/h2
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
python-hyper/h2#1330 ·
-
content-length is not policed when a stream ends with a trailers sectionTalvez já em andamento @feiiiiii5 assumiu há 33 dias. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 76/100
python-hyper/h2#1328 ·
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 35/100
python-hyper/h2#1312 ·
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 35/100
python-hyper/h2#1280 · 2 comentários ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 45/100
python-hyper/h2#1239 · 3 reações ·
Todas as issues de python-hyper/h2
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
btclib-org/btclib-ecc#404 ·
-
changelog investigate
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 78/100
ramnes/notion-sdk-py#430 ·
-
bug good first issue
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 91/100
hyeonjoong/debussy#56 ·
-
README устарел: статус проекта, версия 0.1.0 при описании тега v0.1.1, семантика фолбэка поискаAbertadocumentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Lagrunge82/yandex-mail-mcp#43 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
liberation-data/drivine-python#252 · 1 comentário ·
Mantenedores costumam responder em até 1 dia