mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Fixed #17286 -- Made sure all cache backends are set up to connect to the signal handler that closes the cache connection when the request has been processed. Thanks, gnosek.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17479 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
13
django/core/cache/__init__.py
vendored
13
django/core/cache/__init__.py
vendored
@@ -176,12 +176,13 @@ def get_cache(backend, **kwargs):
|
||||
except (AttributeError, ImportError), e:
|
||||
raise InvalidCacheBackendError(
|
||||
"Could not find backend '%s': %s" % (backend, e))
|
||||
return backend_cls(location, params)
|
||||
cache = backend_cls(location, params)
|
||||
# Some caches -- python-memcached in particular -- need to do a cleanup at the
|
||||
# end of a request cycle. If the cache provides a close() method, wire it up
|
||||
# here.
|
||||
if hasattr(cache, 'close'):
|
||||
signals.request_finished.connect(cache.close)
|
||||
return cache
|
||||
|
||||
cache = get_cache(DEFAULT_CACHE_ALIAS)
|
||||
|
||||
# Some caches -- python-memcached in particular -- need to do a cleanup at the
|
||||
# end of a request cycle. If the cache provides a close() method, wire it up
|
||||
# here.
|
||||
if hasattr(cache, 'close'):
|
||||
signals.request_finished.connect(cache.close)
|
||||
|
||||
Reference in New Issue
Block a user