Just what I was looking for. Thanks. In my case I want to close the database connection because my program briefly talks to django in the beginning, and then runs for an hour. I've got a lot of these running and don't want to hog the mysql connections.
I have an offline process that runs every night -- it can make ~10k updates when it runs. About once every 10 days, the site stops working and I have to restart PostgreSQL and then Apache. If I do Apache first, the site doesn't come back up.
The only suspisious thing in the logs are a lot of these in the Postgres log: 2012-02-08 17:02:55 UTC LOG: unexpected EOF on client connection 2012-02-08 18:54:05 UTC LOG: could not receive data from client: Connection reset by peer
Anyway, I'm saying all this because I put a manual db.close_connection() at the end of my script and that message doesn't appear anymore. I have a feeling that the site will not have to restarted in 10 days time either.
This tiny little piece of code just ended a two-day long troubleshooting fest. I feel like I can take the two minutes to write a thank you to let you know you seriously saved my sanity!
Just what I was looking for. Thanks. In my case I want to close the database connection because my program briefly talks to django in the beginning, and then runs for an hour. I've got a lot of these running and don't want to hog the mysql connections.
ReplyDeleteI have an offline process that runs every night -- it can make ~10k updates when it runs. About once every 10 days, the site stops working and I have to restart PostgreSQL and then Apache. If I do Apache first, the site doesn't come back up.
ReplyDeleteThe only suspisious thing in the logs are a lot of these in the Postgres log:
2012-02-08 17:02:55 UTC LOG: unexpected EOF on client connection
2012-02-08 18:54:05 UTC LOG: could not receive data from client: Connection reset by peer
Anyway, I'm saying all this because I put a manual db.close_connection() at the end of my script and that message doesn't appear anymore. I have a feeling that the site will not have to restarted in 10 days time either.
So thanks!!
This tiny little piece of code just ended a two-day long troubleshooting fest. I feel like I can take the two minutes to write a thank you to let you know you seriously saved my sanity!
ReplyDeleteYou just saved me a few more hours of debugging. Thanks!
ReplyDelete