You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by GitBox <gi...@apache.org> on 2019/08/07 20:19:01 UTC

[GitHub] [libcloud] Kami edited a comment on issue #1339: Various fixes for the Backblaze B2 driver

Kami edited a comment on issue #1339: Various fixes for the Backblaze B2 driver
URL: https://github.com/apache/libcloud/pull/1339#issuecomment-519251656
 
 
   @tonybaloney I noticed more storage drivers use ``response.response`` in ``download_object_as_stream`` method.
   
   This attribute is an instance of ``HttpLibResponseProxy`` which is not compatible with the pre-requests migration response format so those methods will fail / throw an exception:
   
   ```bash
   Traceback (most recent call last):
     File "example_storage.py", line 42, in <module>
       for chunk in iterator:
     File "/home/kami/w/lc/libcloud/libcloud/utils/files.py", line 74, in read_in_chunks
       chunk = b(get_data(*args))
     File "/home/kami/w/lc/libcloud/libcloud/utils/py3.py", line 203, in next
       return iterator.next()
   AttributeError: 'HttpLibResponseProxy' object has no attribute 'next'
   ```
   
   Or am I missing something?
   
   If that's is indeed the issue and it's broken, one option to make it work out of the box (and also be backward compatible) is to add ``next()`` method to ``HttpLibResponseProxy`` class.
   
   Something along the lines of:
   
   ```python
   
       def next(self):
           for chunk in self._response.iter_content():
               return chunk
   ```
   
   I confirmed that works, at least with the Backblaze driver.
   
   It's not the most ideal thing though. Alternative would be to update all those places to use ``response.iter_content()``.
   
   EDIT: If we go with the second approach, do we even still need ``HttpLibResponseProxy`` class at that point? Or maybe some other code still depends on it?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services