I am trying to build some resiliency into our API. The consumers are
our internal python scripts. The backend has sqlalchemy 0.2.8,
psycopg2, and a postgresql 8.1.6 database.
I am wondering if there isn't a better way to handle connection issues
than how I am doing it (see the sample below)?
One test that I have performed is to connect to the database and then
shut it down just before issuing a query. I had been getting the
ProgrammignError class from psycopg2. I also recently caught an
InterfaceError from psycopg2 when I tried to reconnect to the
database. It seems as though I need to handle all class types in
psycopg2?
Thanks in advance,
Rick
===========
def getColumnData(tablename, column):
for numTries in range(MAX_RETRIES_OPERATION):
try:
result = ORM_TABLE_TYPE[tablename].select().execute()
break
except:
# Strangely enough, we get a class type and not an
exception instance.
if sys.exc_type is psycopg2.ProgrammingError:
sleep(RETRY_SLEEP_SECS)
reconnectDB()
else:
raise
else:
raise vmexceptions.ConnectionError, 'Maximum number of retries
exceeded.'
return [i[column] for i in result.fetchall()]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---