Re: handling database restarts

2008-09-06 Thread msoulier
On Sep 3, 3:44 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > Hi Mike, > > Assuming that the DB restarts are rare, consider surrounding your > processing loop with a try..except block. When the exception occurs, > close the current connection so that the next iteration of your loop > gets a fresh

Re: handling database restarts

2008-09-03 Thread Rajesh Dhawan
Hi Mike, > > Now, I took a guess that if I closed the db connection, the framework > would open a new one, so I added this to each processing loop. > > from django.db import connection > > connection.close() > > and this seems to work. No more exceptions when the db is restarted. > > Now, I coul

handling database restarts

2008-09-03 Thread msoulier
I have a long-running process that, to save on code, is using the Django models used in the web app to access the database. ie. os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings' sys.path.append(os.path.abspath('/path/to/django/project')) from myapp.subapp.models import MyModel This work