Skip to content

engine/base -> safe_close_cursor assumes our connection has a _logger #3063

Closed
@sqlalchemy-bot

Description

@sqlalchemy-bot
Collaborator

Migrated issue, originally created by Michael Bayer (@zzzeek)

it's very tough to figure out how to reproduce this one. If you get a non-disconnect exception, but an unclosable cursor within first connect, the exception is squashed because we have a DBAPI connection in first_connect, not a connection fairy.

    def _safe_close_cursor(self, cursor):
        """Close the given cursor, catching exceptions
        and turning into log warnings.

        """
        try:
            cursor.close()
        except (SystemExit, KeyboardInterrupt):
            raise
        except Exception:
            self.connection._logger.error(
                                    "Error closing cursor", exc_info=True)

Activity

sqlalchemy-bot

sqlalchemy-bot commented on May 30, 2014

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

  • vastly improve the "safe close cursor" tests in test_reconnect
  • Fixed bug which would occur if a DBAPI exception
    occurs when the engine first connects and does its initial checks,
    and the exception is not a disconnect exception, yet the cursor
    raises an error when we try to close it. In this case the real
    exception would be quashed as we tried to log the cursor close
    exception via the connection pool and failed, as we were trying
    to access the pool's logger in a way that is inappropriate
    in this very specific scenario. fixes engine/base -> safe_close_cursor assumes our connection has a _logger #3063

814637e

sqlalchemy-bot

sqlalchemy-bot commented on May 30, 2014

@sqlalchemy-bot
CollaboratorAuthor

Michael Bayer (@zzzeek) wrote:

  • vastly improve the "safe close cursor" tests in test_reconnect
  • Fixed bug which would occur if a DBAPI exception
    occurs when the engine first connects and does its initial checks,
    and the exception is not a disconnect exception, yet the cursor
    raises an error when we try to close it. In this case the real
    exception would be quashed as we tried to log the cursor close
    exception via the connection pool and failed, as we were trying
    to access the pool's logger in a way that is inappropriate
    in this very specific scenario. fixes engine/base -> safe_close_cursor assumes our connection has a _logger #3063

758dc17

sqlalchemy-bot

sqlalchemy-bot commented on May 30, 2014

@sqlalchemy-bot
CollaboratorAuthor

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
added
bugSomething isn't working
engineengines, connections, transactions, isolation levels, execution options
on Nov 27, 2018
added this to the 0.9.5 milestone on Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingengineengines, connections, transactions, isolation levels, execution options

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sqlalchemy-bot

        Issue actions

          engine/base -> safe_close_cursor assumes our connection has a _logger · Issue #3063 · sqlalchemy/sqlalchemy