# Path: ciao_contrib/logger_wrapper.py
# def initialize_module_logger(name):
#     """Create a logger for the module with an id of name.
# 
#     Returns the logger. Unlike initialize_logger, no handler
#     is set up.
# 
#     """
# 
#     return get_module_logger(name)


import time
import multiprocessing
import pickle
from queue import Empty
from ..logger_wrapper import initialize_module_logger

class TaskRunner:
    """Given a set of tasks with pre-conditions,
    run them in order. The tasks can be added to
    at any time before the run_tasks method is
    called.

    The task names and preconditions just need to
    be objects that can be displayed, compared
    for equality/used in a set, and can be pickled
    (although strings are primarily used/tested).
    """

    def __init__(self):
        """Set up the task runner."""

        self._clean()

    def _clean(self):
        "Prepare for a new set of tasks"

        self._torun = {}
        self._names = set()

    def _seen(self, name):
        """Returns True if the runner has already been
        sent a task called name."""

        return name in self._names


# Path: ciao_contrib/logger_wrapper.py
# def initialize_module_logger(name):
#     """Create a logger for the module with an id of name.
# 
#     Returns the logger. Unlike initialize_logger, no handler
#     is set up.
# 
#     """
# 
#     return get_module_logger(name)


# Path: ciao_contrib/_tools/taskrunner.py
import time
import multiprocessing
import pickle
from queue import Empty
from ..logger_wrapper import initialize_module_logger


class TaskRunner:
    """Given a set of tasks with pre-conditions,
    run them in order. The tasks can be added to
    at any time before the run_tasks method is
    called.

    The task names and preconditions just need to
    be objects that can be displayed, compared
    for equality/used in a set, and can be pickled
    (although strings are primarily used/tested).
    """

    def __init__(self):
        """Set up the task runner."""

        self._clean()

    def _clean(self):
        "Prepare for a new set of tasks"

        self._torun = {}
        self._names = set()

    def _seen(self, name):
        """Returns True if the runner has already been
        sent a task called name."""

        return name in self._names


    def add_task(self, name, preconditions, func,