# Path: google/cloud/ndb/_eventloop.py
# class EventLoop(object):
#     def __init__(self):
#     def clear(self):
#     def insort_event_right(self, event):
#     def call_soon(self, callback, *args, **kwargs):
#     def queue_call(self, delay, callback, *args, **kwargs):
#     def queue_rpc(self, rpc, callback):
#         def rpc_callback(rpc):
#     def add_idle(self, callback, *args, **kwargs):
#     def run_idle(self):
#     def _run_current(self):
#     def run0(self):
#     def run1(self):
#     def run(self):
# def get_event_loop():
# def add_idle(callback, *args, **kwargs):
# def call_soon(callback, *args, **kwargs):
# def queue_call(delay, callback, *args, **kwargs):
# def queue_rpc(future, rpc):
# def run():
# def run1():
# 
# Path: google/cloud/ndb/exceptions.py
# class Error(Exception):
# class ContextError(Error):
# class BadValueError(Error):
# class BadArgumentError(Error):
# class BadRequestError(Error):
# class Rollback(Error):
# class BadQueryError(Error):
# class BadFilterError(Error):
# class NoLongerImplementedError(NotImplementedError):
# class Cancelled(Error):
# class NestedRetryException(Error):
#     def __init__(self):
#     def __init__(self, filter):
#     def __init__(self):
# 
# Path: google/cloud/ndb/_remote.py
# class RemoteCall(object):
#     def __init__(self, future, info):
#         def record_time(future):
#     def __repr__(self):
#     def exception(self):
#     def result(self):
#     def add_done_callback(self, callback):
#         def wrapper(rpc):
#     def cancel(self):


import functools
import types
from google.cloud.ndb import _eventloop
from google.cloud.ndb import exceptions
from google.cloud.ndb import _remote
        from google.cloud.ndb import context as context_module
        from google.cloud.ndb import context as context_module
    from google.cloud.ndb import context as context_module
            self.set_exception(error)
            return

        # This tasklet has yielded a value. We expect this to be a future
        # object (either NDB or gRPC) or a sequence of futures, in the case of
        # parallel yield.

        def done_callback(yielded):
            # To be called when a future dependency has completed.  Advance the
            # tasklet with the yielded value or error.
            #
            # It was tempting to call `_advance_tasklet` (`_help_tasklet_along`
            # in Legacy) directly. Doing so, it has been found, can lead to
            # exceeding the maximum recursion depth. Queuing it up to run on
            # the event loop avoids this issue by keeping the call stack
            # shallow.
            self.waiting_on = None

            error = yielded.exception()
            if error:
                self.context.eventloop.call_soon(self._advance_tasklet, error=error)
            else:
                self.context.eventloop.call_soon(
                    self._advance_tasklet, yielded.result()
                )

        if isinstance(yielded, Future):
            yielded.add_done_callback(done_callback)
            self.waiting_on = yielded


# Path: google/cloud/ndb/_eventloop.py
# class EventLoop(object):
#     def __init__(self):
#     def clear(self):
#     def insort_event_right(self, event):
#     def call_soon(self, callback, *args, **kwargs):
#     def queue_call(self, delay, callback, *args, **kwargs):
#     def queue_rpc(self, rpc, callback):
#         def rpc_callback(rpc):
#     def add_idle(self, callback, *args, **kwargs):
#     def run_idle(self):
#     def _run_current(self):
#     def run0(self):
#     def run1(self):
#     def run(self):
# def get_event_loop():
# def add_idle(callback, *args, **kwargs):
# def call_soon(callback, *args, **kwargs):
# def queue_call(delay, callback, *args, **kwargs):
# def queue_rpc(future, rpc):
# def run():
# def run1():
# 
# Path: google/cloud/ndb/exceptions.py
# class Error(Exception):
# class ContextError(Error):
# class BadValueError(Error):
# class BadArgumentError(Error):
# class BadRequestError(Error):
# class Rollback(Error):
# class BadQueryError(Error):
# class BadFilterError(Error):
# class NoLongerImplementedError(NotImplementedError):
# class Cancelled(Error):
# class NestedRetryException(Error):
#     def __init__(self):
#     def __init__(self, filter):
#     def __init__(self):
# 
# Path: google/cloud/ndb/_remote.py
# class RemoteCall(object):
#     def __init__(self, future, info):
#         def record_time(future):
#     def __repr__(self):
#     def exception(self):
#     def result(self):
#     def add_done_callback(self, callback):
#         def wrapper(rpc):
#     def cancel(self):


# Path: google/cloud/ndb/tasklets.py
import functools
import types
from google.cloud.ndb import _eventloop
from google.cloud.ndb import exceptions
from google.cloud.ndb import _remote
        from google.cloud.ndb import context as context_module
        from google.cloud.ndb import context as context_module
    from google.cloud.ndb import context as context_module

            self.set_exception(error)
            return

        # This tasklet has yielded a value. We expect this to be a future
        # object (either NDB or gRPC) or a sequence of futures, in the case of
        # parallel yield.

        def done_callback(yielded):
            # To be called when a future dependency has completed.  Advance the
            # tasklet with the yielded value or error.
            #
            # It was tempting to call `_advance_tasklet` (`_help_tasklet_along`
            # in Legacy) directly. Doing so, it has been found, can lead to
            # exceeding the maximum recursion depth. Queuing it up to run on
            # the event loop avoids this issue by keeping the call stack
            # shallow.
            self.waiting_on = None

            error = yielded.exception()
            if error:
                self.context.eventloop.call_soon(self._advance_tasklet, error=error)
            else:
                self.context.eventloop.call_soon(
                    self._advance_tasklet, yielded.result()
                )

        if isinstance(yielded, Future):
            yielded.add_done_callback(done_callback)
            self.waiting_on = yielded


        elif isinstance(yielded, _remote.RemoteCall):