diff options
| author | Jannis Leidel <jannis@leidel.info> | 2012-02-09 18:58:25 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2012-02-09 18:58:25 +0000 |
| commit | c609b792f74948bc4e485ebfcb456ef1b6f8ce0a (patch) | |
| tree | 5b04b598ae0a513a0abd8063c6ac65230cfce155 /django/core/cache/__init__.py | |
| parent | 75c60e80536552125f014fde15e2964ec128c65c (diff) | |
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
Diffstat (limited to 'django/core/cache/__init__.py')
| -rw-r--r-- | django/core/cache/__init__.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py index b97c7469bb..346deae916 100644 --- a/django/core/cache/__init__.py +++ b/django/core/cache/__init__.py @@ -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) |
