# Path: kale/queue_info.py
# class TaskQueue(object):
# class QueueInfoBase(object):
# class QueueInfo(QueueInfoBase):
#     def __init__(self, name='default', priority=5, num_iterations=2,
#                  long_poll_time_sec=5, batch_size=5,
#                  visibility_timeout_sec=600):
#     def _decorate_name(self, name):
#     def get_queues(self):
#     def get_highest_priority_queue_that_needs_work(self):
#     def is_queue_empty(self, queue):
#     def does_queue_need_work(self, queue):
#     def __init__(self, config_file, sqs_talk, queue_cls=TaskQueue):
#     def get_queue(self, simple_name):
#     def get_queues(self):
#     def get_highest_priority_queue_that_needs_work(self):
#     def is_queue_empty(self, queue):
#     def does_queue_need_work(self, queue):
#     def _get_queues_from_config(cls, config_file, queue_cls):
# 
# Path: kale/queue_selector.py
# class SelectQueueBase(object):
# class Random(SelectQueueBase):
# class Lottery(SelectQueueBase):
# class HighestPriorityFirst(SelectQueueBase):
# class HighestPriorityLottery(Lottery):
# class LotteryLottery(Lottery):
# class ReducedLottery(Lottery):
#     def __init__(self, queue_info):
#     def get_queue(self, *args, **kwargs):
#     def get_queue(self):
#     def _run_lottery(queues):
#     def get_queue(self, *args, **kwargs):
#     def get_queue(self, *args, **kwargs):
#     def get_queue(self, *args, **kwargs):
#     def get_queue(self, *args, **kwargs):
#     def get_queue(self, *args, **kwargs):


import argparse
import csv
import logging
import os
import threading
import time
import six
import six.moves.queue
from six.moves import range
from kale import queue_info
from kale import queue_selector
                # We want to keep track of long polling occurrences, which is
                # a waste of compute resource.
                self.queue_info.queues[queue.name].long_polling_count += 1


class PublisherThread(threading.Thread):
    """Publishing tasks."""

    def __init__(self, tasks, publish_interval, queue_info):
        """
        Args:
            tasks: A list of tasks, each is a 2-tuple
                (queue_name, running_time).
            publish_interval: Integer for task publishing interval in secs.
        """
        self.tasks = tasks
        self.queue_info = queue_info
        self.publish_interval = publish_interval
        super(PublisherThread, self).__init__()

    def run(self):
        """The main function for publisher."""
        global all_done
        log.info('Running publisher thread %d ...' % self.ident)
        while len(self.tasks) > 0:
            task = self.tasks.pop()
            task_entry = {
                'publish_time': time.time(),
                'finished_consumption_time': 0.0,
                'running_time': task[1]}

# Path: kale/queue_info.py
# class TaskQueue(object):
# class QueueInfoBase(object):
# class QueueInfo(QueueInfoBase):
#     def __init__(self, name='default', priority=5, num_iterations=2,
#                  long_poll_time_sec=5, batch_size=5,
#                  visibility_timeout_sec=600):
#     def _decorate_name(self, name):
#     def get_queues(self):
#     def get_highest_priority_queue_that_needs_work(self):
#     def is_queue_empty(self, queue):
#     def does_queue_need_work(self, queue):
#     def __init__(self, config_file, sqs_talk, queue_cls=TaskQueue):
#     def get_queue(self, simple_name):
#     def get_queues(self):
#     def get_highest_priority_queue_that_needs_work(self):
#     def is_queue_empty(self, queue):
#     def does_queue_need_work(self, queue):
#     def _get_queues_from_config(cls, config_file, queue_cls):
# 
# Path: kale/queue_selector.py
# class SelectQueueBase(object):
# class Random(SelectQueueBase):
# class Lottery(SelectQueueBase):
# class HighestPriorityFirst(SelectQueueBase):
# class HighestPriorityLottery(Lottery):
# class LotteryLottery(Lottery):
# class ReducedLottery(Lottery):
#     def __init__(self, queue_info):
#     def get_queue(self, *args, **kwargs):
#     def get_queue(self):
#     def _run_lottery(queues):
#     def get_queue(self, *args, **kwargs):
#     def get_queue(self, *args, **kwargs):
#     def get_queue(self, *args, **kwargs):
#     def get_queue(self, *args, **kwargs):
#     def get_queue(self, *args, **kwargs):


# Path: kale/scripts/benchmark_queue_selector.py
import argparse
import csv
import logging
import os
import threading
import time
import six
import six.moves.queue
from six.moves import range
from kale import queue_info
from kale import queue_selector

                # We want to keep track of long polling occurrences, which is
                # a waste of compute resource.
                self.queue_info.queues[queue.name].long_polling_count += 1


class PublisherThread(threading.Thread):
    """Publishing tasks."""

    def __init__(self, tasks, publish_interval, queue_info):
        """
        Args:
            tasks: A list of tasks, each is a 2-tuple
                (queue_name, running_time).
            publish_interval: Integer for task publishing interval in secs.
        """
        self.tasks = tasks
        self.queue_info = queue_info
        self.publish_interval = publish_interval
        super(PublisherThread, self).__init__()

    def run(self):
        """The main function for publisher."""
        global all_done
        log.info('Running publisher thread %d ...' % self.ident)
        while len(self.tasks) > 0:
            task = self.tasks.pop()
            task_entry = {
                'publish_time': time.time(),
                'finished_consumption_time': 0.0,
                'running_time': task[1]}

            self.queue_info.queues[task[0]].tasks.put(task_entry)