-
Notifications
You must be signed in to change notification settings - Fork 38
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 upload for large BytesIO #1780
Conversation
Nice! |
Hey, super thanks for the PR and especially for the new test! I am a little concerned that simply removing the context manager will cause other problems though — this code path is also used when uploading files from disk, and I think that this change risks leaving those file handles open. I need to look a little bit more closely though — It's definitely a little trick to follow the code here. |
You a re right @mwaskom, good catch! How do we proceed? |
Ooops didn't mean to close/re-open 😅 What makes this tricky is that when the user passes The only solution I can think of that doesn't involve copying the whole payload into memory (which would not be great when a user passes a large @mwaskom can you think of a better solution? |
Thanks for the test @sveinnfannar, made an implementation in this PR #1962 that seems to work |
Great! Closing this then 👍 |
Describe your changes
Uploading a BytesIO over 4MiB results in a
ValueError: I/O operation on closed file
due to the stream being closed twice. Once when checking the file size and again when uploading. This PR make sure the stream is not closed when checking the file size. The PR also includes a test to reproduce the error.Slack thread about the issue.
Changelog