You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File.download hangs when downloading a ~230 MB tgz file. I waited 10+ minutes, but never long enough to see it terminate. I have not tried enough files to produce a minimal working example.
Based on traceback when cancelling mid-operation, the library appears hung in this try/except block:
...
File "/Users/gondree/anaconda/envs/hob/lib/python3.6/site-packages/canvasapi/file.py", line 32, in download
response = self._requester.request("GET", _url=self.url)
File "/Users/gondree/anaconda/envs/hob/lib/python3.6/site-packages/canvasapi/requester.py", line 226, in request
logger.debug("Data: {data}".format(data=pformat(response.json())))
File "/Users/gondree/anaconda/envs/hob/lib/python3.6/site-packages/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/Users/gondree/anaconda/envs/hob/lib/python3.6/site-packages/requests/models.py", line 858, in text
encoding = self.apparent_encoding
File "/Users/gondree/anaconda/envs/hob/lib/python3.6/site-packages/requests/models.py", line 728, in apparent_encoding
return chardet.detect(self.content)['encoding']
File "/Users/gondree/anaconda/envs/hob/lib/python3.6/site-packages/chardet/__init__.py", line 38, in detect
detector.feed(byte_str)
File "/Users/gondree/anaconda/envs/hob/lib/python3.6/site-packages/chardet/universaldetector.py", line 211, in feed
if prober.feed(byte_str) == ProbingState.FOUND_IT:
File "/Users/gondree/anaconda/envs/hob/lib/python3.6/site-packages/chardet/charsetgroupprober.py", line 71, in feed
state = prober.feed(byte_str)
File "/Users/gondree/anaconda/envs/hob/lib/python3.6/site-packages/chardet/sbcharsetprober.py", line 79, in feed
byte_str = self.filter_international_words(byte_str)
File "/Users/gondree/anaconda/envs/hob/lib/python3.6/site-packages/chardet/charsetprober.py", line 87, in filter_international_words
buf)
File "/Users/gondree/anaconda/envs/hob/lib/python3.6/re.py", line 222, in findall
return _compile(pattern, flags).findall(string)
Expected behavior
The expected behavior is that the file gets downloaded, no matter the size and no matter the contents.
Environment information
Python version (python --version)
$ python --version
Python 3.6.2 :: Continuum Analytics, Inc.
CanvasAPI version (pip show canvasapi)
Name: canvasapi
Version: 0.16.0
Summary: API wrapper for the Canvas LMS
Home-page: https://github.com/ucfopen/canvasapi
Author: University of Central Florida - Center for Distributed Learning
Author-email: techrangers@ucf.edu
License: MIT License
Location: /Users/gondree/anaconda/envs/hob/lib/python3.6/site-packages
Requires: requests, pytz, six
Required-by:
The simplest fix for me was avoiding the operations when not debugging:
if logger.isEnabledFor(logging.DEBUG):
try:
logger.debug("Data: {data}".format(data=pformat(response.json())))
except ValueError:
logger.debug("Data: {data}".format(data=pformat(response.text)))
This solved my problem. It would not be ideal if you ever needed to debug in a situation involving one of these problematic downloads. Reporting in hope that this, or a more clever fix, can be incorporated.
The text was updated successfully, but these errors were encountered:
* Fix rtype in request method
* Should fix#386 by avoiding call to response.text while logging as response may contain binary data
* Add option for File.get_contents to return bytes instead of a string
* Add test for a response that returns invalid unicode + run formatter
Co-authored-by: Matthew Emond <me@ucf.edu>
Describe the bug
File.download hangs when downloading a ~230 MB tgz file. I waited 10+ minutes, but never long enough to see it terminate. I have not tried enough files to produce a minimal working example.
Based on traceback when cancelling mid-operation, the library appears hung in this try/except block:
Specifically, its hung performing
response.json()
Expected behavior
The expected behavior is that the file gets downloaded, no matter the size and no matter the contents.
Environment information
python --version
)pip show canvasapi
)Additional context
I tried to implement a timeout, like:
But, generally, that did not work correctly.
The simplest fix for me was avoiding the operations when not debugging:
This solved my problem. It would not be ideal if you ever needed to debug in a situation involving one of these problematic downloads. Reporting in hope that this, or a more clever fix, can be incorporated.
The text was updated successfully, but these errors were encountered: