from twisted.python import failure
import sipb_xen_database
+import psycopg2
+import sqlalchemy
+import time
class DatabaseAuthority(common.ResolverBase):
"""An Authority that is loaded from a file."""
serial=1, refresh=3600, retry=900,
expire=3600000, minimum=21600, ttl=3600)
def _lookup(self, name, cls, type, timeout = None):
+ for i in range(3):
+ try:
+ value = self._lookup_unsafe(name, cls, type, timeout = None)
+ except (psycopg2.OperationalError, sqlalchemy.exceptions.SQLError):
+ if i == 2:
+ raise
+ print "Reloading database"
+ time.sleep(0.5)
+ continue
+ else:
+ return value
+
+ def _lookup_unsafe(self, name, cls, type, timeout):
sipb_xen_database.clear_cache()
if not (name.lower() == self.domain or
name.lower().endswith('.'+self.domain)):