diff options
| author | Anssi Kääriäinen <akaariai@gmail.com> | 2013-02-12 23:11:22 +0200 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-02-13 00:25:09 +0200 |
| commit | fafee74306e869c23edcef864f9d816565a5c4a2 (patch) | |
| tree | f4b6f3a0dd9ecf069f78c1450ad6b37ed23a84f4 /django | |
| parent | c4841b3de4ffe0047dfc2d3435c22e77b0f98d86 (diff) | |
Removed try-except in django.db.close_connection()
The reason was that the except clause needed to remove a connection
from the django.db.connections dict, but other parts of Django do not
expect this to happen. In addition the except clause was silently
swallowing the exception messages.
Refs #19707, special thanks to Carl Meyer for pointing out that this
approach should be taken.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/__init__.py | 13 | ||||
| -rw-r--r-- | django/db/utils.py | 3 |
2 files changed, 5 insertions, 11 deletions
diff --git a/django/db/__init__.py b/django/db/__init__.py index 94eca13d41..32e42bbfe9 100644 --- a/django/db/__init__.py +++ b/django/db/__init__.py @@ -45,14 +45,11 @@ def close_connection(**kwargs): # Avoid circular imports from django.db import transaction for conn in connections: - try: - transaction.abort(conn) - connections[conn].close() - except Exception: - # The connection's state is unknown, so it has to be - # abandoned. This could happen for example if the network - # connection has a failure. - del connections[conn] + # If an error happens here the connection will be left in broken + # state. Once a good db connection is again available, the + # connection state will be cleaned up. + transaction.abort(conn) + connections[conn].close() signals.request_finished.connect(close_connection) # Register an event that resets connection.queries diff --git a/django/db/utils.py b/django/db/utils.py index 943e3e3f73..91fa774ed4 100644 --- a/django/db/utils.py +++ b/django/db/utils.py @@ -99,9 +99,6 @@ class ConnectionHandler(object): def __setitem__(self, key, value): setattr(self._connections, key, value) - def __delitem__(self, key): - delattr(self._connections, key) - def __iter__(self): return iter(self.databases) |
