try: doTransactionProcessing() except KeyboardInterrupt: commit() except: #all other exceptions rollback() else: commit