@utils.decorator<EOL>def non_transactional(func, args, kwds, allow_existing=True):
from . import tasklets<EOL>ctx = tasklets.get_context()<EOL>if not ctx.in_transaction():<EOL><INDENT>return func(*args, **kwds)<EOL><DEDENT>if not allow_existing:<EOL><INDENT>raise datastore_errors.BadRequestError(<EOL>'<STR_LIT>' % func.__name__)<EOL><DEDENT>save_ctx = ctx<EOL>while ctx.in_transaction():<EOL><INDENT>ctx = ctx._parent_context<EOL>if ctx is None:<EOL><INDENT>raise datastore_errors.BadRequestError(<EOL>'<STR_LIT>')<EOL><DEDENT><DEDENT>save_ds_conn = datastore._GetConnection()<EOL>try:<EOL><INDENT>if hasattr(save_ctx, '<STR_LIT>'):<EOL><INDENT>datastore._SetConnection(save_ctx._old_ds_conn)<EOL><DEDENT>tasklets.set_context(ctx)<EOL>return func(*args, **kwds)<EOL><DEDENT>finally:<EOL><INDENT>tasklets.set_context(save_ctx)<EOL>datastore._SetConnection(save_ds_conn)<EOL><DEDENT>
A decorator that ensures 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:
      allow_existing: If false, throw an exception if called from within
        a transaction.  If true, temporarily re-establish the
        previous non-transactional context.  Defaults to True.

    This supports two forms, similar to transactional().

    Returns:
      A wrapper for the decorated function that ensures it runs outside a
      transaction.