Skip to content

Commit

Permalink
Check DEFAULT_TIMEOUT (Django 1.6+)
Browse files Browse the repository at this point in the history
There is a new DEFAULT_TIMEOUT object in Django which is checked when timeout is not set.
It has been introduced in:
django/django@89955cc

The problem was that this has been passed to uWSGI because it has not been checked and the uWSGI
cache_update function expects an integer not an object() instace, so it gave a TypeError.

Also check settings.py default values the same way as it be would passed to function call.
(So we need to check every value in _set() which comes from settings.py.)
  • Loading branch information
Kiss György committed Jul 12, 2016
1 parent 04fb1f8 commit f7dcc03
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/uwsgicache.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.utils.encoding import force_bytes as stringify
except ImportError:
from django.utils.encoding import smart_str as stringify
from django.core.cache.backends.base import BaseCache, InvalidCacheBackendError
from django.core.cache.backends.base import BaseCache, InvalidCacheBackendError, DEFAULT_TIMEOUT
from django.conf import settings

try:
Expand Down Expand Up @@ -52,9 +52,10 @@ def get(self, key, default=None, version=None):
return pickle.loads(val)

def _set(self, full_key, value, timeout):
if timeout is True:
if timeout is True or timeout == DEFAULT_TIMEOUT:
uwsgi_timeout = self.default_timeout
elif timeout is None or timeout is False:

if timeout is None or timeout is False:
# Django 1.6+: Explicitly passing in timeout=None will set a non-expiring timeout.
uwsgi_timeout = 0
elif timeout == 0:
Expand Down

0 comments on commit f7dcc03

Please sign in to comment.