Sujet : Re: psycopg2: proper positioning of .commit() within try: except: blocks
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.pythonDate : 08. Sep 2024, 13:57:45
Autres entêtes
Organisation : Stefan Ram
Message-ID : <rollback-20240908125702@ram.dialup.fu-berlin.de>
References : 1 2 3 4 5 6 7 8 9 10
Jon Ribbens <jon+
usenet@unequivocal.eu> wrote or quoted:
What if there's an exception in your exception handler? I'd put the
rollback in the 'finally' handler, so it's always called.
To make this happen, you'd better kick off with the rollback right
at the beginning of the "finally:" block. Otherwise, some gnarly
exception might rear its ugly head before the rollback gets called!