Mercurial > public > sg101
diff core/download.py @ 980:3ebde23a59d0
Pass timeout to requests instead of global timeout.
Global timeout didn't seem to work once we started using requests.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 15 Oct 2015 18:35:56 -0500 |
parents | a6331579ff43 |
children | ef1558941bc9 |
line wrap: on
line diff
--- a/core/download.py Fri Oct 09 22:20:32 2015 -0500 +++ b/core/download.py Thu Oct 15 18:35:56 2015 -0500 @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) -def download_file(url, path=None): +def download_file(url, path=None, timeout=None): """Downloads the image file from the given source URL and stores it in the filename given by path. If path is None, a temporary file will be created. @@ -24,7 +24,7 @@ logger.info("download_file from %s; path=%s", url, path) try: - r = requests.get(url, stream=True) + r = requests.get(url, stream=True, timeout=timeout) except requests.RequestException: logger.exception("download_file requests.get('%s') exception", url) raise