-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
raise RuntimeError when a single streamed request calls *iter methods th... #2241
Conversation
Let's have a subclass of |
if self._content_consumed and isinstance(self._content, bool): | ||
raise RuntimeError( | ||
'The content for this response was already consumed') | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the else
or the subsequent indentation, we won't get this far if we raise anyway.
EOFError? |
I think |
Thoughts on making whichever error name we choose multiply inherit from |
Yeah, I can accept that. And |
@tijko so could you update this PR to add the described exception to |
@@ -89,3 +89,6 @@ class ChunkedEncodingError(RequestException): | |||
|
|||
class ContentDecodingError(RequestException, BaseHTTPError): | |||
"""Failed to decode response content""" | |||
|
|||
class StreamConsumedError(RequestException): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to doubly inherit, like so:
class StreamConsumedError(RequestException, TypeError):
@sigmavirus24 looks like @tijko updated this as requested |
@kennethreitz looks good to me |
raise RuntimeError when a single streamed request calls *iter methods th...
In response to issue #2240, add a check to see if the content was "consumed"