summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-04-12 14:38:52 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-04-12 14:38:52 -0400
commit9273cdd6387bdf2182e595bdd5144a1792e9e1a4 (patch)
tree9913e1f2c844107064eb653787ba662d9b58a792 /lib/sqlalchemy/engine/base.py
parent3d66f727f56426592d70d5cf54bbcb891172b6f0 (diff)
downloadsqlalchemy-9273cdd6387bdf2182e595bdd5144a1792e9e1a4.tar.gz
- [bug] If conn.begin() fails when calling
"with engine.begin()", the newly acquired Connection is closed explicitly before propagating the exception onward normally.
Diffstat (limited to 'lib/sqlalchemy/engine/base.py')
-rw-r--r--lib/sqlalchemy/engine/base.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index 110ac4e8a..1d2511333 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -2355,7 +2355,11 @@ class Engine(Connectable, log.Identified):
"""
conn = self.contextual_connect(close_with_result=close_with_result)
- trans = conn.begin()
+ try:
+ trans = conn.begin()
+ except:
+ conn.close()
+ raise
return Engine._trans_ctx(conn, trans, close_with_result)
def transaction(self, callable_, *args, **kwargs):