File tree Expand file tree Collapse file tree 3 files changed +5
-10
lines changed Expand file tree Collapse file tree 3 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -60,8 +60,7 @@ def create_connection(self, alias):
60
60
def close_caches (** kwargs ):
61
61
# Some caches need to do a cleanup at the end of a request cycle. If not
62
62
# implemented in a particular backend cache.close() is a no-op.
63
- for cache in caches .all (initialized_only = True ):
64
- cache .close ()
63
+ caches .close_all ()
65
64
66
65
67
66
signals .request_finished .connect (close_caches )
Original file line number Diff line number Diff line change @@ -190,14 +190,6 @@ def create_connection(self, alias):
190
190
backend = load_backend (db ["ENGINE" ])
191
191
return backend .DatabaseWrapper (db , alias )
192
192
193
- def close_all (self ):
194
- for alias in self :
195
- try :
196
- connection = getattr (self ._connections , alias )
197
- except AttributeError :
198
- continue
199
- connection .close ()
200
-
201
193
202
194
class ConnectionRouter :
203
195
def __init__ (self , routers = None ):
Original file line number Diff line number Diff line change @@ -79,3 +79,7 @@ def all(self, initialized_only=False):
79
79
# If initialized_only is True, return only initialized connections.
80
80
if not initialized_only or hasattr (self ._connections , alias )
81
81
]
82
+
83
+ def close_all (self ):
84
+ for conn in self .all (initialized_only = True ):
85
+ conn .close ()
You can’t perform that action at this time.
0 commit comments