Make http.MediaFileUpload close its file descriptor.#600
Merged
tseaver merged 2 commits intoJul 17, 2019
Conversation
tseaver
suggested changes
Dec 7, 2018
Contributor
tseaver
left a comment
There was a problem hiding this comment.
Thank you for the patch! In addition to my comment inline, can you please add a testcase in tests/test_http.py which exercises the new code? Something like:
class TestMediaUpload(unittest.TestCase):
...
def test_media_file_upload_closes_fd_in___del__(self):
file_desc = mock.Mock(spec=['close'])
opener = mock.mock_open(file_desc)
with mock.patch('googleapis.http.open', opener):
upload = MediaFileUpload(datafile('test_close'))
self.assertIs(upload.stream(), file_desc)
del upload
file_desc.close.assert_called_once_with()| """ | ||
| self._filename = filename | ||
| fd = open(self._filename, 'rb') | ||
| self._fd = open(self._filename, 'rb') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Contributor
Author
|
Thanks very much for your review! |
busunkim96
approved these changes
Jul 17, 2019
tseaver
approved these changes
Jul 17, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #575