human
Solve the following python programming problem given the following code:
@datastore_rpc._positional(1)
def NonTransactional(_func=None, allow_existing=True):
assistant
#Here is the Python program you requested.

    """A decorator that insures a function is run outside a transaction.
    If there is an existing transaction (and allow_existing=True), the existing
    transaction is paused while the function is executed.
    Args:
    _func: do not use
    allow_existing: If false, throw an exception if called from within a
    transaction
    Returns:
    A wrapper for the decorated function that ensures it runs outside a
    transaction.
    """
    if (_func is not None):
        return NonTransactional()(_func)
    def outer_wrapper(func):
        def inner_wrapper(*args, **kwds):
            if (not IsInTransaction()):
                return func(*args, **kwds)
            if (not allow_existing):
                raise datastore_errors.BadRequestError('Function    cannot    be    called    from    within    a    transaction.')
            txn_connection = _GetConnection()
            _SetConnection(_thread_local.old_connection)
            try:
                return func(*args, **kwds)
            finally:
                _SetConnection(txn_connection)
        return inner_wrapper
    return outer_wrapper