
from framework.mongo import database as proxy_database


def begin(database=None):
    database = database or proxy_database
    database.command('beginTransaction')


def rollback(database=None):
    database = database or proxy_database
    database.command('rollbackTransaction')


def commit(database=None):
    database = database or proxy_database
    database.command('commitTransaction')


def show_live(database=None):
    database = database or proxy_database
    return database.command('showLiveTransactions')


from framework.mongo import database as proxy_database
from pymongo.errors import OperationFailure


def begin(database=None):
    database = database or proxy_database
    database.command('beginTransaction')


def rollback(database=None):
    database = database or proxy_database
    try:
        database.command('rollbackTransaction')
    except OperationFailure:
        pass


def commit(database=None):
    database = database or proxy_database
    database.command('commitTransaction')


def show_live(database=None):
    database = database or proxy_database
    return database.command('showLiveTransactions')

Fix rollback transaction issue bby adding except for Operation Failure to rollback
Fix rollback transaction issue bby adding except for Operation Failure to rollback

  
  from framework.mongo import database as proxy_database
+ from pymongo.errors import OperationFailure
  
  
  def begin(database=None):
      database = database or proxy_database
      database.command('beginTransaction')
  
  
  def rollback(database=None):
      database = database or proxy_database
+     try:
-     database.command('rollbackTransaction')
+         database.command('rollbackTransaction')
+     except OperationFailure:
+         pass
  
  
  def commit(database=None):
      database = database or proxy_database
      database.command('commitTransaction')
  
  
  def show_live(database=None):
      database = database or proxy_database
      return database.command('showLiveTransactions')
  
Fix rollback transaction issue bby adding except for Operation Failure to rollback
## Code Before:

from framework.mongo import database as proxy_database


def begin(database=None):
    database = database or proxy_database
    database.command('beginTransaction')


def rollback(database=None):
    database = database or proxy_database
    database.command('rollbackTransaction')


def commit(database=None):
    database = database or proxy_database
    database.command('commitTransaction')


def show_live(database=None):
    database = database or proxy_database
    return database.command('showLiveTransactions')

## Instruction:
Fix rollback transaction issue bby adding except for Operation Failure to rollback
## Code After:

from framework.mongo import database as proxy_database
from pymongo.errors import OperationFailure


def begin(database=None):
    database = database or proxy_database
    database.command('beginTransaction')


def rollback(database=None):
    database = database or proxy_database
    try:
        database.command('rollbackTransaction')
    except OperationFailure:
        pass


def commit(database=None):
    database = database or proxy_database
    database.command('commitTransaction')


def show_live(database=None):
    database = database or proxy_database
    return database.command('showLiveTransactions')
