# 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
            try:
                traceback = self._exception.__traceback__
            except AttributeError:  # pragma: NO PY3 COVER  # pragma: NO BRANCH
                # Python 2 does not have the helpful traceback attribute, and
                # since the exception is not being handled, it appears that
                # sys.exec_info can't give us the traceback either.
                traceback = None
            return traceback

    def add_done_callback(self, callback):
        """Add a callback function to be run upon task completion. Will run
        immediately if task has already finished.

        Args:
            callback (Callable): The function to execute.
        """
        if self._done:
            callback(self)
        else:
            self._callbacks.append(callback)

    def cancel(self):
        """Attempt to cancel the task for this future.

        If the task has already completed, this call will do nothing.
        Otherwise, this will attempt to cancel whatever task this future is
        waiting on. There is no specific guarantee the underlying task will be
        cancelled.
        """
        if not self.done():

# 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

            try:
                traceback = self._exception.__traceback__
            except AttributeError:  # pragma: NO PY3 COVER  # pragma: NO BRANCH
                # Python 2 does not have the helpful traceback attribute, and
                # since the exception is not being handled, it appears that
                # sys.exec_info can't give us the traceback either.
                traceback = None
            return traceback

    def add_done_callback(self, callback):
        """Add a callback function to be run upon task completion. Will run
        immediately if task has already finished.

        Args:
            callback (Callable): The function to execute.
        """
        if self._done:
            callback(self)
        else:
            self._callbacks.append(callback)

    def cancel(self):
        """Attempt to cancel the task for this future.

        If the task has already completed, this call will do nothing.
        Otherwise, this will attempt to cancel whatever task this future is
        waiting on. There is no specific guarantee the underlying task will be
        cancelled.
        """
        if not self.done():

            self.set_exception(exceptions.Cancelled())