Hi folks, We're using the Django database layer as part of a Twisted application [1], and we're having some problems with Django failing to reconnect to the database after the database server restarts. It works great otherwise, but once the database server restarts, the Django database layer throws exceptions on every database touch. Is there any way to configure Django (or psycopg2) to automatically reconnect?
The traceback we're seeing is below [2]. The problem is reliably reproducible by restarting Postgres, then triggering an action in our Twisted application that touches the database. It persists until we restart the application. Versions: Django 1.2.1 Psycopg2 2.0.13 Postgresql 8.4.5 Ubuntu 10.04 Thanks, -Brennan [1] We're planning on adding a real Django app in the near future, and wanted to maintain the same database abstraction throughout the system. [2] Traceback: File "/usr/lib/pymodules/python2.6/gjeter/executive/Executive.py", line 164, in robotPair p.save() File "/usr/lib/pymodules/python2.6/django/db/models/base.py", line 435, in save self.save_base(using=using, force_insert=force_insert, force_update=force_update) File "/usr/lib/pymodules/python2.6/django/db/models/base.py", line 528, in save_base result = manager._insert(values, return_id=update_pk, using=using) File "/usr/lib/pymodules/python2.6/django/db/models/manager.py", line 195, in _insert return insert_query(self.model, values, **kwargs) File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 1479, in insert_query return query.get_compiler(using=using).execute_sql(return_id) File "/usr/lib/pymodules/python2.6/django/db/models/sql/compiler.py", line 783, in execute_sql cursor = super(SQLInsertCompiler, self).execute_sql(None) File "/usr/lib/pymodules/python2.6/django/db/models/sql/compiler.py", line 727, in execute_sql cursor.execute(sql, params) File "/usr/lib/pymodules/python2.6/django/db/backends/util.py", line 15, in execute return self.cursor.execute(sql, params) File "/usr/lib/pymodules/python2.6/django/db/backends/postgresql_psycopg2/base.py", line 44, in execute return self.cursor.execute(query, args) django.db.utils.DatabaseError: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.