'Transactionally retrieves an existing entity or creates a new one.
This is the asynchronous version of Model._get_or_insert().'

@classmethod
def _get_or_insert_async(*args, **kwds):

    from . import tasklets
    (cls, name) = args
    get_arg = cls.__get_arg
    app = get_arg(kwds, 'app')
    namespace = get_arg(kwds, 'namespace')
    parent = get_arg(kwds, 'parent')
    context_options = get_arg(kwds, 'context_options')
    if (not isinstance(name, basestring)):
        raise TypeError(('name    must    be    a    string;    received    %r' % name))
    elif (not name):
        raise ValueError('name    cannot    be    an    empty    string.')
    key = Key(cls, name, app=app, namespace=namespace, parent=parent)
    @tasklets.tasklet
    def internal_tasklet():
        @tasklets.tasklet
        def txn():
            ent = (yield key.get_async(options=context_options))
            if (ent is None):
                ent = cls(**kwds)
                ent._key = key
                (yield ent.put_async(options=context_options))
            raise tasklets.Return(ent)
        if in_transaction():
            ent = (yield txn())
        else:
            ent = (yield key.get_async(options=context_options))
            if (ent is None):
                ent = (yield transaction_async(txn))
        raise tasklets.Return(ent)
    return internal_tasklet()
