@classmethod<EOL><INDENT>def _get_or_insert_async(*args, **kwds):<DEDENT>
<EOL>from . import tasklets<EOL>cls, name = args  <EOL>get_arg = cls.__get_arg<EOL>app = get_arg(kwds, '<STR_LIT>')<EOL>namespace = get_arg(kwds, '<STR_LIT>')<EOL>parent = get_arg(kwds, '<STR_LIT>')<EOL>context_options = get_arg(kwds, '<STR_LIT>')<EOL>if not isinstance(name, basestring):<EOL><INDENT>raise TypeError('<STR_LIT>' % name)<EOL><DEDENT>elif not name:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>key = Key(cls, name, app=app, namespace=namespace, parent=parent)<EOL>@tasklets.tasklet<EOL>def internal_tasklet():<EOL><INDENT>@tasklets.tasklet<EOL>def txn():<EOL><INDENT>ent = yield key.get_async(options=context_options)<EOL>if ent is None:<EOL><INDENT>ent = cls(**kwds)  <EOL>ent._key = key<EOL>yield ent.put_async(options=context_options)<EOL><DEDENT>raise tasklets.Return(ent)<EOL><DEDENT>if in_transaction():<EOL><INDENT>ent = yield txn()<EOL><DEDENT>else:<EOL><INDENT>ent = yield key.get_async(options=context_options)<EOL>if ent is None:<EOL><INDENT>ent = yield transaction_async(txn)<EOL><DEDENT><DEDENT>raise tasklets.Return(ent)<EOL><DEDENT>return internal_tasklet()<EOL>
Transactionally retrieves an existing entity or creates a new one.

        This is the asynchronous version of Model._get_or_insert().