On Aug 30, 2007, at 6:41 PM, Mike Orr wrote:

>
> On 8/30/07, Moshe C. <[EMAIL PROTECTED]> wrote:
>>
>> I was hoping there was something more elegant than just trying and
>> catching a possible exception.
>> The motivation is just simpler and more readable code like
>> if not connection.is_valid():
>>    get another one
>
> The issue is that in a packet-based network, there's no way to tell if
> the connection is alive without generating some traffic and seeing if
> it succeeds.  SQLAlchemy could, and perhaps should, encapsulate this
> in a method but it doesn't.  I've also argued that SQLAlchemy should
> seamlessly retry a query if it finds a connection dead, but MikeB says
> this is not safe in a transaction.
>
> The SQLAlchemy Way is to set the 'pool_recycle' engine option to a
> value lower than the database's timeout.  MySQL seems to be the main
> culprit, and it has a default timeout of 8 hours or so, so setting
> pool_recycle=3600 (one hour) is well within the limit.
>

we have  a mechanism now such that a "connection pre-pinger" could be  
wired into the connection pool using a pool extension.   Jason  
Kirtland has built the framework for it and I've asked that we have a  
standard "pre-ping" plugin available, or possibly just via a regular  
keyword argument.  it will slow performance down a little bit.

however in most cases keeping a low pool_recycle should take care of  
most common issues in this area...

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
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