py-oauth2
py-oauth2 copied to clipboard
Large file cause MemoryError
Hi there, it's me again.
Since the last time I asked about download large file streamly via OAuth2
, I eventually found there's possibly a bug in your code. I noticed an unnormal RAM usage which would even use up all RAM on old computers. This happens during the last few seconds of downloading a file (50+ MB).
And I found this is somethins related to this line: https://github.com/liluo/py-oauth2/blob/313f195639cd94c7cce47c9a83e71dae487e53e9/pyoauth2/libs/response.py#L29
If changed to:
options = {'parse': 'text'}
options.update(opts)
if options['parse'] in ('text', 'query', 'json', ):
self.body = response.text
would solve this problem, and also lower the RAM usage during small size file downloading.
options = {'parse': 'text'}
options.update(opts)
self.options = options
if options['parse'] in ('text', 'query', 'json', ):
self.body = response.text