Skip to content

Commit

Permalink
Always use process cache to be on safe side of cross-process locking
Browse files Browse the repository at this point in the history
  • Loading branch information
bjester committed Jun 25, 2020
1 parent 198701a commit 7679955
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions kolibri/core/tasks/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from kolibri.core.tasks import compat
from kolibri.core.utils.cache import DiskCacheRLock
from kolibri.core.utils.cache import process_cache


# An object on which to store data about the current job
Expand Down Expand Up @@ -121,4 +120,4 @@ def shutdown(self):
self.stop()


db_task_write_lock = DiskCacheRLock(process_cache, "db_task_write_lock")
db_task_write_lock = DiskCacheRLock("db_task_write_lock")
8 changes: 3 additions & 5 deletions kolibri/core/utils/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class DiskCacheRLock(object):
https://github.com/grantjenks/python-diskcache/blob/2d1f43ea2be4c82a430d245de6260c3e18059ba1/diskcache/recipes.py
"""

def __init__(self, cache, key, expire=None):
self._cache = cache
def __init__(self, key, expire=None):
self._cache = process_cache
self._key = key
self._expire = expire

Expand Down Expand Up @@ -82,9 +82,7 @@ def __init__(self, cache, namespace, **params):
params.update(KEY_PREFIX=namespace)
super(NamespacedCacheProxy, self).__init__(params)
self.cache = cache
self._lock = DiskCacheRLock(
process_cache, "namespaced_cache_{}".format(namespace)
)
self._lock = DiskCacheRLock("namespaced_cache_{}".format(namespace))

def _get_keys(self):
"""
Expand Down

0 comments on commit 7679955

Please sign in to comment.