On Mar 16, 2010, at 8:09 PM, Julian Scheid wrote:

> I'm looking for a way to close a pooled connection client-side after a
> certain period, say when it wasn't used in 30 seconds. I don't think
> any of the Pool implementations that come with SQLAlchemy supports
> this. Does anybody know of a third-party implementation with this
> functionality? I guess it wouldn't be difficult to create one from
> scratch but I was hoping that there is an existing solution.


*All* of the pool implementations support this, with the caveat that its 
recycled on next checkout.  See "pool_recycle" at 
http://www.sqlalchemy.org/docs/reference/sqlalchemy/connections.html?highlight=create_engine#sqlalchemy.create_engine
 .

You can also force any connection to recycle immediately using 
connection.invalidate():

http://www.sqlalchemy.org/docs/reference/sqlalchemy/connections.html?highlight=create_engine#sqlalchemy.create_engine

if you truly wanted a checked out connection to automatically invalidate itself 
while checked out,  you definitely need to forego using any transactions with 
it (i.e. autocommit for everything), and you can create a ConnectionProxy that 
calls invalidate() when an execute() call is received more than 30 seconds 
since the last one.  ConnectionProxy is at 
http://www.sqlalchemy.org/docs/reference/sqlalchemy/interfaces.html#sqlalchemy.interfaces.ConnectionProxy
 .



> 
> Thanks,
> 
> Julian
> 
> -- 
> 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.
> 

-- 
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