diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-03-07 14:47:50 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-03-11 15:05:04 +0100 |
| commit | 423c0d5e293bf6bd5f859430126269c31313585a (patch) | |
| tree | 40df4241d973cc8418c4f92c6033524183db6d0b | |
| parent | 107d9b1d974ae97132751cb1db742fd8e930fb89 (diff) | |
Added a safety net for developers messing with autocommit.
| -rw-r--r-- | django/db/backends/__init__.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 2d1de9509e..cb17e1db61 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -417,12 +417,19 @@ class BaseDatabaseWrapper(object): or if it outlived its maximum age. """ if self.connection is not None: + # If the application didn't restore the original autocommit setting, + # don't take chances, drop the connection. + if self.autocommit != self.settings_dict['AUTOCOMMIT']: + self.close() + return + if self.errors_occurred: if self.is_usable(): self.errors_occurred = False else: self.close() return + if self.close_at is not None and time.time() >= self.close_at: self.close() return |
