Added a safety net for developers messing with autocommit.
This commit is contained in:
parent
107d9b1d97
commit
423c0d5e29
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue