
Il giorno lun, 14-02-2005 alle 13:16 -0800, snacktime ha scritto:
Also, I *think* one of the reasons that adbapi doesn't have logic to try and reconnect is that it might be difficult to detect under what conditions you want to attempt a reconnect. The error messages for a lost connection might be different from module to module. For example a telling the difference between a timed out connection and the database server just being down. With psycopg OperationalError gets you pretty much everything that would mean you need to reconnect as far as I can tell.
From the definition of OperationalError it should be pretty safe to (try to) reconnect whenever you get it. It owuld be nice to have a cofigurable number of reconnection attempts directly in ConnectionPool.
From PEP-249:
OperationalError Exception raised for errors that are related to the database's operation and not necessarily under the control of the programmer, e.g. an unexpected disconnect occurs, the data source name is not found, a transaction could not be processed, a memory allocation error occurred during processing, etc. It must be a subclass of DatabaseEr federico