On 11/7/06, Arturo FMwrote: > >I don't need cleanup but I've found that expecting a long-running db > >connection to stay open is unwise. MySQL will unilaterally abandon > >connections after so many idle hours (12 or so), and if MySQL is > >restarted the connection is no longer valid either, while it appears > >open in the Quixote application until you do a query, at which point > >you get a "MySQL server has gone away" exception. Unfortunately I > >didn't realize this when I wrote a few applications, so now I have a > >cron job that restarts them every N hours as a kludge. The proper way > >would be to use a "smart reconnect" connection from SQLAlchemy or some > >other db modules. These reconnect and retry the query if the > >connection is dead. > > I think this issue is a limitation. I'm working with MySQL but "MySQL server has gone away" is a problem because I need to write a cron job or use a third party module for reconnect to database. On the other hand, I can open a connection, execute a query and close the connection but it isn't efficient because open a db connection cost very time. Can I use Medusa or Twisted for solve this problem? The smart reconnect modules also have connection pooling. It will leave unused connections open and hand them back to the next routine that asks for one. SQLAlchemy has this and there's also a standalone module I'm planning to try, although I can't find the link to it now. SQLObject has the same feature but I'm not sure if you can use it alone (without SQLObject's OO features). -- Mike Orr