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 utils.is_fileobj for streaming responses from requests #805

Closed
davisp opened this Issue Jun 26, 2014 · 2 comments

Comments

Projects
None yet
3 participants
@davisp
Collaborator

davisp commented Jun 26, 2014

Turns out that the utils.is_fileobj breaks for streamed responses from the requests library due to how we check for a fileno() function and the exception raised by urllib3.

https://github.com/benoitc/gunicorn/blob/19.0/gunicorn/util.py#L511-L521
https://github.com/kennethreitz/requests/blob/v2.3.0/requests/packages/urllib3/response.py#L294-L301

Obvious fix is to add the IOError type to the exception list. PR to follow shortly.

@davisp davisp added the Bug label Jun 26, 2014

davisp added a commit that referenced this issue Jun 26, 2014

Fix check for file-like objects
The `is_fileobject()` function in utils.py would break when the respones
was a wrapped `HTTPResponse`'s `raw` attribute. This just adds the
`IOError` exception type to the `is_fileobject()` function so that the
response can be streamed normally.

Fixes #805

@tilgovi tilgovi closed this in #806 Jun 26, 2014

@fmarczin

This comment has been minimized.

Show comment
Hide comment
@fmarczin

fmarczin Nov 24, 2015

This bug can still be triggered by file-like objects which wrap objects without a .fileno() method. This happened to me in combination with pyfilesystem (https://github.com/PyFilesystem/pyfilesystem/blob/master/fs/iotools.py#L31).

The simplest fix would be to add AttributeError to the list of exceptions, just like in the commit above (fc364cc).

fmarczin commented Nov 24, 2015

This bug can still be triggered by file-like objects which wrap objects without a .fileno() method. This happened to me in combination with pyfilesystem (https://github.com/PyFilesystem/pyfilesystem/blob/master/fs/iotools.py#L31).

The simplest fix would be to add AttributeError to the list of exceptions, just like in the commit above (fc364cc).

@tilgovi

This comment has been minimized.

Show comment
Hide comment
@tilgovi

tilgovi Nov 25, 2015

Collaborator

@fmarczin this code isn't used anymore on master as of 6b92575. If you could reproduce problems before and can check again on master that would be great.

Collaborator

tilgovi commented Nov 25, 2015

@fmarczin this code isn't used anymore on master as of 6b92575. If you could reproduce problems before and can check again on master that would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment