On Dec 21, 2008, at 11:24 PM, Bobby Impollonia wrote:

>
> I occasionally have a query fail with 'Lost connection to MySQL server
> during query' which gets converted into a
> sqlalchemy.exceptions.OperationalError. I have not been able to figure
> out why it happens, but the server should always be available.
>
> I would like to tell sqlalchemy that if a query fails with this error,
> it should wait a few seconds and then retry the query (and probably
> give up if it fails again). Does SQLA provide some sort of hooks that
> would allow me to do this without gnarly monkey patching?

you'd have to organize your code such that the desired operation can  
be attempted again when this exception is raised.

This is a pretty tough road to travel, though, since if the connection  
is lost, so is your entire transaction and everything you've loaded/ 
persisted within it.   A better approach would be to isolate the cause  
of the error.    This error is commonly caused by a MySQL client  
timeout (usually on a connection that's been idle for 8 hours) and is  
allevated using the pool_recycle=<some number of seconds> option.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to