Andreas
I have had to use this workaround for scripts that run a long time between database accesses:
from django.db import connection
def checkConnection():
# Check the connection, close if needed
try:
connection.connection.ping()
# print 'INFO: connection.connection.ping()'
except:
connection.close()
# print 'INFO: connection.close()'
Call checkConnection() before you do a database access, you may need to play around with where you put this. The code I have is crawler which uses the django models to add data to a database, so a lot of time elapses between the start of the script and when the data is actually inserted into the database, so plenty of time for connections to time out.
I spent a while tracking this down a while back but was not able to fully sort out the issue, I came away with the impression that there was a bug somewhere in the connection pool code. If you like I have a little spare time today and can dig into this again.
François
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CALXYUbmPrpEwHbrNn29HQ_%2BtDGYgeCdeV9PqyikJLq9C-V2zdQ%40mail.gmail.com.