Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#16533 closed Bug (fixed)

pylibmc cache backend raises an exception for float timeouts

Reported by: jbalogh Owned by: jbalogh
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 jbalogh 4 years ago.
Force timeouts to be ints in get_memcache_timeout

Download all attachments as: .zip

Change History (5)

Changed 4 years ago by jbalogh

Force timeouts to be ints in get_memcache_timeout

comment:1 Changed 4 years ago by jbalogh

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Sorry about the nasty formatting.

comment:2 Changed 4 years ago by jezdez

  • Triage Stage changed from Unreviewed to Ready for checkin

comment:3 Changed 4 years ago by jezdez

  • Resolution set to fixed
  • Status changed from new to closed

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 Changed 4 years ago by jacob

  • milestone 1.4 deleted

Milestone 1.4 deleted

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