Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(asgi.BoundedStream): Mixing iteration and read() can lead to subtle errors #1692

Merged
merged 2 commits into from
Mar 3, 2020

Conversation

kgriffs
Copy link
Member

@kgriffs kgriffs commented Feb 29, 2020

Summary of Changes

This patch does three things to make BoundedStream more robust and debuggable:

  1. Disallow re-iteration over the stream when an iteration is already in progress.
  2. Yield anything in the buffer first, before awaiting additional body events,
    when iterating over a stream that was partially read before the iteration
    began.
  3. Introduce a custom subclass of ValueError, OperationNotAllowed, that
    can be raised to give the developer a more obvious hint as to what
    went wrong.

Related Issues

#1358

…le errors

This patch does three things to make BoundedStream more robust and debuggable:

1. Disallow re-iteration over the stream when an iteration is already in progress.
2. Yield anything in the buffer first, before awaiting additional body events,
   when iterating over a stream that was partially read before the iteration
   began.
3. Introduce a custom subclass of ValueError, OperationNotAllowed, that
   can be raised to give the developer a more obvious hint as to what
   went wrong.
@codecov
Copy link

codecov bot commented Feb 29, 2020

Codecov Report

Merging #1692 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master     #1692   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           47        47           
  Lines         3537      3548   +11     
  Branches       548       550    +2     
=========================================
+ Hits          3537      3548   +11     

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad88bc4...3605d76. Read the comment docs.

Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@vytas7 vytas7 merged commit e9b4b76 into falconry:master Mar 3, 2020
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