Skip to content

Commit

Permalink
Added a timeout setting to use with urllib2 when retrieving an image …
Browse files Browse the repository at this point in the history
…with a URL. Without the timeout setting, urllib2 will wait indefinitely for a response.
  • Loading branch information
nschwane committed Mar 5, 2012
1 parent f446f91 commit 272bf5f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions sorl/thumbnail/conf/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,6 @@
# or height given
THUMBNAIL_DUMMY_RATIO = 1.5

# Timeout, in seconds, to use when retrieving images with urllib2
THUMBNAIL_URL_TIMEOUT = None

2 changes: 1 addition & 1 deletion sorl/thumbnail/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def url(self):

class UrlStorage(Storage):
def open(self, name):
return urllib2.urlopen(name)
return urllib2.urlopen(name, None, settings.THUMBNAIL_URL_TIMEOUT)

def exists(self, name):
try:
Expand Down

0 comments on commit 272bf5f

Please sign in to comment.