#9626 closed (fixed)
Bug in Cache when calling has_key
Reported by: | anonymous | Owned by: | nobody |
---|---|---|---|
Component: | Core (Cache system) | Version: | 1.0 |
Severity: | Keywords: | cache, has_key, KeyError, locmem, del | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
File "/var/django/mydjangoapp/../mydjangoapp/stories/context_processors.py", line 5, in get_cached_num
if not cache.has_key(which):
File "/var/lib/python-support/python2.4/django/core/cache/backends/locmem.py", line 99, in has_key
del self._cache[key]
KeyError: 'authors'
i do not think, its a bug in my code, when django tries to delete a item, for which i am checking if it even exists.
Change History (6)
comment:1 by , 16 years ago
milestone: | post-1.0 |
---|
comment:2 by , 16 years ago
milestone: | → 1.1 |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 16 years ago
As far as I can see, this can only be caused by a thread race, since by the time the line of code in question is executed, we know the key was in the cache from a few lines earlier. I'm avoiding that, but this shouldn't be happening in normal operations, since the locmem cache isn't particularly appropriate for user between multiple threads (every other cache backend is better).
comment:4 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:5 by , 16 years ago
Malcolm, while you are at it, can you please take a look at #9644 as well? It's the same thing, only in a different location.
Milestone post-1.0 deleted