Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#16533 closed Bug (fixed)

pylibmc cache backend raises an exception for float timeouts

Reported by: Jeff Balogh Owned by: Jeff Balogh
Component: Core (Cache system) Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If the pylibmc is passed a float timeout it crashes with TypeError: integer argument expected, got float.

CACHES = {

'default': {

'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
'LOCATION': '0:11211', },

'memcache': { 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',

'LOCATION': '0:11211', },

}
In [1]: from django.core.cache import get_cache
In [2]: get_cache('default').set('a', 1, 1.3) ---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/Users/jbalogh/dev/zamboni/<ipython console> in <module>()
/Users/jbalogh/dev/zamboni/vendor/src/django/django/core/cache/backends/memcached.py in set(self, key, value, timeout, version)

63 def set(self, key, value, timeout=0, version=None): 64 key = self.make_key(key, version=version)

---> 65 self._cache.set(key, value, self._get_memcache_timeout(timeout)) 66

67 def delete(self, key, version=None):

TypeError: integer argument expected, got float
In [3]: get_cache('memcache').set('a', 1, 1.3)

I don't condone this behavior but piston triggered the crash and it's a regression from memcache.py

Attachments (1)

float-cache-timeout.diff (1.4 KB ) - added by Jeff Balogh 13 years ago.
Force timeouts to be ints in get_memcache_timeout

Download all attachments as: .zip

Change History (5)

by Jeff Balogh, 13 years ago

Attachment: float-cache-timeout.diff added

Force timeouts to be ints in get_memcache_timeout

comment:1 by Jeff Balogh, 13 years ago

Sorry about the nasty formatting.

comment:2 by Jannis Leidel, 13 years ago

Triage Stage: UnreviewedReady for checkin

comment:3 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

In [16556]:

Fixed #16533 -- Stopped the memcache cache backend from raising an exception if the timeout value isn't an integer. Thanks, Jeff Balogh.

comment:4 by Jacob, 13 years ago

milestone: 1.4

Milestone 1.4 deleted

Note: See TracTickets for help on using tickets.
Back to Top