How to handle disconnect on connection pools - Mailing list psycopg

From Diego Pasqualin
Subject How to handle disconnect on connection pools
Date
Msg-id CADpKL+1=1KsZ1CeuPdmWkoKJ1c2DeVi2Nm_B+mrQiQ-GgNUwdQ@mail.gmail.com
Whole thread Raw
Responses Re: How to handle disconnect on connection pools  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
List psycopg
Hi, 

I have an application with many threads using a PersistentConnectionPool.
It works great, until someone restarts the database, disconnecting all connections in the pool.

So, what can I do to recover the connections when the server restart?

I was thinking about catching psycopg2.OperationalError in a try/except statement, executing a pool.putconn(conn, close=True) to close the problematic connection, then trying to execute the SQL query again. Though, I'm not sure if the PersistentConnectionPool class would create a new connection afterwards, or if this is the right way to do it...

Thanks,

--
  Diego G. Pasqualin
  UFPR - Universidade Federal do Paraná
  C3SL - Centro de Computação Científica e Software Livre

psycopg by date:

Previous
From: "W. Matthew Wilson"
Date:
Subject: Re: Can't register python class for domain?
Next
From: Daniele Varrazzo
Date:
Subject: Re: How to handle disconnect on connection pools