'Close the given cursor, catching exceptions
and turning into log warnings.'

def _safe_close_cursor(self, cursor):

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