Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a safety net for developers messing with autocommit.

  • Loading branch information...
commit 423c0d5e293bf6bd5f859430126269c31313585a 1 parent 107d9b1
@aaugustin aaugustin authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 django/db/backends/__init__.py
View
7 django/db/backends/__init__.py
@@ -417,12 +417,19 @@ def close_if_unusable_or_obsolete(self):
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

0 comments on commit 423c0d5

Please sign in to comment.
Something went wrong with that request. Please try again.