Ah, yeah, that seems like a reasonable way of handling it.

I just don't get why I'm getting those exceptions, though, as I have it set
to recycle pool connections every 4 hrs where the mysql setting is to
expire connections after 8hrs.  As far as I understand it, I shouldn't be
getting messages like that.  Or are the pool connections "recycled" just
before the next use and not after 4hrs elapse?

-Tim


On 27 March 2014 11:44, Michael Bayer <mike...@zzzcomputing.com> wrote:

>
> On Mar 27, 2014, at 10:03 AM, Tim Tisdall <tisd...@gmail.com> wrote:
>
> > Today I found the following traceback in my logs:
> >
> > 2014-03-27 13:55:59,876 ERROR [sqlalchemy.pool.QueuePool
> _close_connection b'uWSGIWorker2Core14'] Exception closing connection
> <oursql.Connection object at 0x7fecfdf6a140>
> > Traceback (most recent call last):
> >   File
> "/sites/ColanderAlchemy/SQLAlchemy-0.9.3-py3.3-linux-x86_64.egg/sqlalchemy/pool.py",
> line 243, in _close_connection
> >     self._dialect.do_close(connection)
> >   File
> "/sites/ColanderAlchemy/SQLAlchemy-0.9.3-py3.3-linux-x86_64.egg/sqlalchemy/engine/default.py",
> line 401, in do_close
> >     dbapi_connection.close()
> >   File "connection.pyx", line 193, in oursql.Connection.close
> (oursqlx/oursql.c:6143)
> >   File "connection.pyx", line 240, in oursql.Connection.rollback
> (oursqlx/oursql.c:6562)
> >   File "connection.pyx", line 207, in oursql.Connection._raise_error
> (oursqlx/oursql.c:6317)
> > oursql.OperationalError: (2006, 'MySQL server has gone away', None)
> >
> > Shouldn't SQLAlchemy closing a connection catch this type of exception
> and ignore it?  If the mysql connection "has gone away", can it not be
> considered "closed"?
>
> there's a difference between "ignore" and "silent". Here's the code:
>
>     def _close_connection(self, connection):
>         self.logger.debug("Closing connection %r", connection)
>         try:
>             self._dialect.do_close(connection)
>         except (SystemExit, KeyboardInterrupt):
>             raise
>         except:
>             self.logger.error("Exception closing connection %r",
>                             connection, exc_info=True)
>
> as you can see, the error is ignored, we just log that something
> unexpected and possibly problematic has happened.    I don't think this is
> necessarily a bad thing.
>
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "sqlalchemy" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/sqlalchemy/K9Pk2pXbLgQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to