+ 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):