From 7827dfb6726a682c630d66b24423582d5dc09589 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 21 Sep 2016 15:37:20 -0400 Subject: Handle BaseException in all _handle_dbapi_error Tests illustrate that exceptions like GreenletExit and even KeyboardInterrupt can corrupt the state of a DBAPI connection like that of pymysql and mysqlclient. Intercept BaseException errors within the handle_error scheme and invalidate just the connection alone in this case, but not the whole pool. The change is backwards-incompatible with a program that currently intercepts ctrl-C within a database transaction and wants to continue working on that transaction. Ensure the event hook can be used to reverse this behavior. Change-Id: Ifaa013c13826d123eef34e32b7e79fff74f1b21b Fixes: #3803 --- lib/sqlalchemy/engine/default.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/engine/default.py') diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index bd6e37d6c..733a89076 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -961,7 +961,7 @@ class DefaultExecutionContext(interfaces.ExecutionContext): inputsizes.append(dbtype) try: self.cursor.setinputsizes(*inputsizes) - except Exception as e: + except BaseException as e: self.root_connection._handle_dbapi_exception( e, None, None, None, self) else: @@ -979,7 +979,7 @@ class DefaultExecutionContext(interfaces.ExecutionContext): inputsizes[key] = dbtype try: self.cursor.setinputsizes(**inputsizes) - except Exception as e: + except BaseException as e: self.root_connection._handle_dbapi_exception( e, None, None, None, self) -- cgit v1.2.1