-
Notifications
You must be signed in to change notification settings - Fork 925
[LIBCLOUD-639] Python 3 Error: "Invalid argument %r for b()" when using upload_object_via_stream #408
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
Conversation
…on't need to explain as much magic in an earlier test.
…he chunks, otherwise it turns a 1.6MB file into more than 400MB (when I gave up and killed the request).
| @@ -742,7 +742,8 @@ def _stream_data(self, response, iterator, chunked=False, | |||
| if calculate_hash: | |||
| data_hash = self._get_hash_function() | |||
|
|
|||
| generator = libcloud.utils.files.read_in_chunks(iterator, chunk_size) | |||
| generator = libcloud.utils.files.read_in_chunks(iterator, chunk_size, | |||
| fill_size=True) | |||
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.
Why is the fill_size change necessary?
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.
Refer to my commit message:
"Don't send one byte at a time, read the iterator in chunks and fill the chunks, otherwise it turns a 1.6MB file into more than 400MB (when I gave up and killed the request)."
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.
To be more explicit, I tested this by watching the python3.4 process in the OSX Activity Monitor > Network > Sent Bytes. Without this fix I saw over 400MB uploaded (when I gave up, debugging later revealed the process sending the bytes one at a time, so probably one per packet with all the associated overheads).
With this fix, the process only uploaded a little over the expected 1.6MB for my test file, which makes sense with typical network overheads (wrapping in packets, <1500 Bytes MTU meaning some fragmentation, etc).
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.
Looked at it again in a debugger and it appears this only affects storage drivers with supports_chunked_encoding = True, i.e. the Atmos and Rackspace drivers at this time.
https://github.com/apache/libcloud/blob/ea16988/libcloud/storage/base.py#L634-636
Otherwise it uses the else branch directly below and consumes the entire iterator as already documented:
https://github.com/apache/libcloud/blob/ea16988/libcloud/storage/base.py#L400-408
EDIT: Changed links to include a gitref so they should be stable over time.
|
Can you please paste the whole exception with a stack trace? I'm wondering where an int gets passed to the |
|
Stack trace from running the test: AFAIK that's how Python3 works with However I did notice I only updated one of the three usages of |
|
Or to put it another way, at a raw python 3.4 console: |
|
@Kami Added a regression test for the |
|
@pzrq Sorry for the delay. I was traveling a week ago so I missed your comments. I will go over it and get it merged into trunk asap. |
|
Merged into trunk. Thanks! |
|
Also forgot to say - good catch and improvement on the fill_size thing. |
|
@Kami Thanks for merging. I hope you're enjoying traveling. |
https://issues.apache.org/jira/browse/LIBCLOUD-639