Hi all,

I am using GeoDjango and I have a django-admin command that does some route 
calculations for approximately 24 hours and then saves the results to a 
MySQL database. Unfortunately the database connection times out after 8 
hours resulting in: django.db.utils.OperationalError: (2006, 'MySQL server 
has gone away'). I check in the mysql logs that this is indeed a timeout 
error. It seems to be the case that django is maintaining a persistent 
connection even when I set CONN_MAX_AGE to 60 seconds (although perhaps 
this parameter applies only to requests). Is there a solution to this issue 
without simply increasing the timeout in MySQL?

So far I have tried closing the connections manually using: 

from django.db import connections
connections.close_all()

I also tried simply catching the exception and retrying the write to the 
database (it's stated that Django automatically reopens connections on new 
queries here: 
https://docs.djangoproject.com/en/1.10/ref/databases/#connection-management), 
but the same error occurs. 

I am using Django 1.10 and Python 2.7.12 on Linux, if that helps.

Any help is greatly appreciated. 

Thanks in advance, 

Charanpal

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/aa55fb47-bb33-4e48-b726-c44e5c6ef1ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to