]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Update connection.rst
authorJosep Pascual Badia <joseppascualbadia@gmail.com>
Mon, 30 May 2022 10:56:02 +0000 (12:56 +0200)
committerGitHub <noreply@github.com>
Mon, 30 May 2022 10:56:02 +0000 (12:56 +0200)
Fix a bug on reconnecting logic since at it is right now it is assigning the new connection to a new cursor but is till retrying on the old one.

doc/build/faq/connections.rst

index d592ccf6dc88084f4ff5ea11917dbeceb6d3ec5b..59db00c37b2833d35c239afb42ba39d7f4032667 100644 (file)
@@ -281,7 +281,7 @@ statement executions::
                               trans.rollback()
 
                       time.sleep(retry_interval)
-                      context.cursor = cursor_obj = connection.connection.cursor()
+                      context.cursor = cursor = connection.connection.cursor()
                   else:
                       raise
               else:
@@ -290,15 +290,15 @@ statement executions::
       e = engine.execution_options(isolation_level="AUTOCOMMIT")
 
       @event.listens_for(e, "do_execute_no_params")
-      def do_execute_no_params(cursor_obj, statement, context):
+      def do_execute_no_params(cursor, statement, context):
           return _run_with_retries(
-              context.dialect.do_execute_no_params, context, cursor_obj, statement
+              context.dialect.do_execute_no_params, context, cursor, statement
           )
 
       @event.listens_for(e, "do_execute")
-      def do_execute(cursor_obj, statement, parameters, context):
+      def do_execute(cursor, statement, parameters, context):
           return _run_with_retries(
-              context.dialect.do_execute, context, cursor_obj, statement, parameters
+              context.dialect.do_execute, context, cursor, statement, parameters
           )
 
       return e