# Path: google/cloud/ndb/utils.py
# TRUTHY_STRINGS = {"t", "true", "y", "yes", "on", "1"}
# DEBUG = asbool(os.environ.get("NDB_DEBUG", False))
# def asbool(value):
# def code_info(*args, **kwargs):
# def decorator(*args, **kwargs):
# def frame_info(*args, **kwargs):
# def func_info(*args, **kwargs):
# def gen_info(*args, **kwargs):
# def get_stack(*args, **kwargs):
# def logging_debug(log, message, *args, **kwargs):
#     def __init__(self, **kwargs):
#     def __call__(self, wrapped):
#         def wrapper(*args, **kwargs):
# def positional(max_pos_args):
#     def positional_decorator(wrapped):
#         def positional_wrapper(*args, **kwds):
# def tweak_logging(*args, **kwargs):
# def wrapping(*args, **kwargs):
# class keyword_only(object):


import collections
import logging
import uuid
import time
    import queue
    import Queue as queue
from google.cloud.ndb import utils
            from google.cloud.ndb import context as context_module
    from google.cloud.ndb import context as context_module
            run only when no other RPCs need to be fired first. Used for
            batching calls to the Datastore back end.
        inactive (int): Number of consecutive idlers that were noops. Reset
            to 0 whenever work is done by any callback, not necessarily by an
            idler. Not currently used.
        queue (list): a sorted list of (absolute time in sec, callback, args,
            kwds), sorted by time. These callbacks run only after the said
            time. Used by :func:`tasklets.sleep`.
        rpcs (dict): a map from RPC to callback. Callback is called when the
            RPC finishes.
        rpc_results (queue.Queue): A synchronized queue used to coordinate with
            gRPC. As gRPC futures that we're waiting on are finished, they will
            get added to this queue and then processed by the event loop.
    """

    def __init__(self):
        self.current = collections.deque()
        self.idlers = collections.deque()
        self.inactive = 0
        self.queue = []
        self.rpcs = {}
        self.rpc_results = queue.Queue()

    def clear(self):
        """Remove all pending events without running any."""
        while self.current or self.idlers or self.queue or self.rpcs:
            current = self.current
            idlers = self.idlers
            queue = self.queue
            rpcs = self.rpcs

# Path: google/cloud/ndb/utils.py
# TRUTHY_STRINGS = {"t", "true", "y", "yes", "on", "1"}
# DEBUG = asbool(os.environ.get("NDB_DEBUG", False))
# def asbool(value):
# def code_info(*args, **kwargs):
# def decorator(*args, **kwargs):
# def frame_info(*args, **kwargs):
# def func_info(*args, **kwargs):
# def gen_info(*args, **kwargs):
# def get_stack(*args, **kwargs):
# def logging_debug(log, message, *args, **kwargs):
#     def __init__(self, **kwargs):
#     def __call__(self, wrapped):
#         def wrapper(*args, **kwargs):
# def positional(max_pos_args):
#     def positional_decorator(wrapped):
#         def positional_wrapper(*args, **kwds):
# def tweak_logging(*args, **kwargs):
# def wrapping(*args, **kwargs):
# class keyword_only(object):


# Path: google/cloud/ndb/_eventloop.py
import collections
import logging
import uuid
import time
    import queue
    import Queue as queue
from google.cloud.ndb import utils
            from google.cloud.ndb import context as context_module
    from google.cloud.ndb import context as context_module

            run only when no other RPCs need to be fired first. Used for
            batching calls to the Datastore back end.
        inactive (int): Number of consecutive idlers that were noops. Reset
            to 0 whenever work is done by any callback, not necessarily by an
            idler. Not currently used.
        queue (list): a sorted list of (absolute time in sec, callback, args,
            kwds), sorted by time. These callbacks run only after the said
            time. Used by :func:`tasklets.sleep`.
        rpcs (dict): a map from RPC to callback. Callback is called when the
            RPC finishes.
        rpc_results (queue.Queue): A synchronized queue used to coordinate with
            gRPC. As gRPC futures that we're waiting on are finished, they will
            get added to this queue and then processed by the event loop.
    """

    def __init__(self):
        self.current = collections.deque()
        self.idlers = collections.deque()
        self.inactive = 0
        self.queue = []
        self.rpcs = {}
        self.rpc_results = queue.Queue()

    def clear(self):
        """Remove all pending events without running any."""
        while self.current or self.idlers or self.queue or self.rpcs:
            current = self.current
            idlers = self.idlers
            queue = self.queue
            rpcs = self.rpcs

            utils.logging_debug(log, "Clearing stale EventLoop instance...")