
Il giorno lun, 14-02-2005 alle 21:03 -0500, James Y Knight ha scritto:
On Feb 14, 2005, at 4:05 PM, snacktime wrote:
Attempting reconnects just isn't part of adbapi as far as I can tell.
It is part of adbapi in Twisted 2.0 (see cp_reconnect arg to the DatabasePool constructor). However, it will only reconnect after failing a query. It will never retry a query (that could be unsafe to do), but will re-establish the database connection after that query fails. Thus, subsequent queries will succeed.
If you know some way to tell for sure that it there is no possibility that the query has been executed, you could submit a patch for adbapi that it will retry the query in those circumstances.
If the database support transactions and an exception is raised the DatabasePool does a .rollback() (if I remember correctly). In this case you're sure the query has not been executed (it was rolled back explicitly.) The problem is with backends that do not support transactions, but if you're crazy enough to use one of them having a query repeated is a lesser evil. ;) IMHO, it is safe to rollback, reconnect and send the query again. Maybe a cp_repeat_query=True|False parameter? -- Federico Di Gregorio http://people.initd.org/fog Debian GNU/Linux Developer fog@debian.org INIT.D Developer fog@initd.org Nobody will ever need more than 640k RAM! -- Bill Gates, 1981 Windows 95 needs at least 8 MB RAM. -- Bill Gates, 1996 Nobody will ever need Windows 95. -- logical conclusion