py-oauth2 icon indicating copy to clipboard operation
py-oauth2 copied to clipboard

Large file cause MemoryError

Open JokerQyou opened this issue 10 years ago • 1 comments

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.

JokerQyou avatar Sep 26 '14 07:09 JokerQyou

        options = {'parse': 'text'}
        options.update(opts)
        self.options = options
        if options['parse'] in ('text', 'query', 'json', ):
            self.body = response.text

smileboywtu avatar Mar 24 '16 07:03 smileboywtu