human
Complete this python program:
def _SynchronizeTxn(function):
assistant
#Here is the Python program you requested.

    """A decorator that locks a transaction during the function call.
    """
    def sync(txn, *args, **kwargs):
        txn._lock.acquire()
        try:
            Check((txn._state is LiveTxn.ACTIVE), 'transaction    closed')
            return function(txn, *args, **kwargs)
        finally:
            txn._lock.release()
    return sync