# Path: sio/sioworkersd/scheduler/prioritizing.py
# class _WaitingTasksQueue(object):
# class WorkerInfo(object):
# class TaskInfo(object):
# class ContestInfo(object):
# class TasksQueues(object):
# class PrioritizingScheduler(Scheduler):
#     def __init__(self):
#     def __contains__(self, task):
#     def __len__(self):
#     def __nonzero__(self):
#     def add(self, task):
#     def remove(self, task):
#     def left(self):
#     def popleft(self):
#     def getTasksRequiredRam(self):
#     def __init__(self, wid, wdata):
#     def __lt__(self, other):
#     def getQueueName(self):
#     def getAvailableRam(self):
#     def getAvailableVcpuSlots(self):
#     def attachTask(self, task):
#     def detachTask(self, task):
#     def __init__(self, env, contest):
#     def __init__(self, contest_uid, priority, weight):
#     def __init__(self, random):
#     def __nonzero__(self):
#     def addTask(self, task):
#     def delTask(self, task):
#     def chooseTask(self):
#     def __init__(self, manager):
#     def __unicode__(self):
#     def _insertWorkerToQueue(self, worker):
#     def _removeWorkerFromQueue(self, worker):
#     def addWorker(self, worker_id):
#     def delWorker(self, worker_id):
#     def _getAnyCpuQueueSize(self):
#     def _getBestWorkerForVirtualCpuTask(self, queue, task_ram, prefer_busy=False):
#         def suitability(worker):
#     def _getBestVcpuOnlyWorkerForVirtualCpuTask(self, task_ram):
#     def _getBestAnyCpuWorkerForVirtualCpuTask(self, task_ram):
#     def _getBestAnyCpuWorkerForRealCpuTask(self, task_ram):
#     def updateContest(self, contest_uid, priority, weight):
#     def _addTaskToQueues(self, task):
#     def _removeTaskFromQueues(self, task):
#     def _attachTaskToWorker(self, task, worker):
#     def addTask(self, env):
#     def delTask(self, task_id):
#     def _getNumberOfBlockedAnyCpuWorkers(self):
#     def _scheduleOnce(self):
#     def schedule(self):


import random
import unittest
import six
from sio.sioworkersd.scheduler import prioritizing
from six.moves import range
            'concurrency': 4,
            'ram': 2048,
            'is_real_cpu': False,
        }

        scheduler = prioritizing.PrioritizingScheduler(
            WorkerManagerStub(vcpu_only_worker)
        )

        scheduler.addWorker(1)

        scheduler.updateContest(contest_uid=1, priority=10, weight=10)

        add_task_to_scheduler(scheduler, 1, is_real_cpu=False, ram=1024)
        add_task_to_scheduler(scheduler, 2, is_real_cpu=False, ram=512)
        add_task_to_scheduler(scheduler, 3, is_real_cpu=False, ram=1024)

        scheduled_tasks = scheduler.schedule()

        # Third task should be blocked.
        six.assertCountEqual(self, [(1, 1), (2, 1)], scheduled_tasks)

    def test_should_respect_concurrency_limits_when_assigning_vcpu_tasks(self):
        vcpu_only_worker = {
            'id': 1,
            'concurrency': 2,
            'ram': 8192,
            'is_real_cpu': False,
        }


# Path: sio/sioworkersd/scheduler/prioritizing.py
# class _WaitingTasksQueue(object):
# class WorkerInfo(object):
# class TaskInfo(object):
# class ContestInfo(object):
# class TasksQueues(object):
# class PrioritizingScheduler(Scheduler):
#     def __init__(self):
#     def __contains__(self, task):
#     def __len__(self):
#     def __nonzero__(self):
#     def add(self, task):
#     def remove(self, task):
#     def left(self):
#     def popleft(self):
#     def getTasksRequiredRam(self):
#     def __init__(self, wid, wdata):
#     def __lt__(self, other):
#     def getQueueName(self):
#     def getAvailableRam(self):
#     def getAvailableVcpuSlots(self):
#     def attachTask(self, task):
#     def detachTask(self, task):
#     def __init__(self, env, contest):
#     def __init__(self, contest_uid, priority, weight):
#     def __init__(self, random):
#     def __nonzero__(self):
#     def addTask(self, task):
#     def delTask(self, task):
#     def chooseTask(self):
#     def __init__(self, manager):
#     def __unicode__(self):
#     def _insertWorkerToQueue(self, worker):
#     def _removeWorkerFromQueue(self, worker):
#     def addWorker(self, worker_id):
#     def delWorker(self, worker_id):
#     def _getAnyCpuQueueSize(self):
#     def _getBestWorkerForVirtualCpuTask(self, queue, task_ram, prefer_busy=False):
#         def suitability(worker):
#     def _getBestVcpuOnlyWorkerForVirtualCpuTask(self, task_ram):
#     def _getBestAnyCpuWorkerForVirtualCpuTask(self, task_ram):
#     def _getBestAnyCpuWorkerForRealCpuTask(self, task_ram):
#     def updateContest(self, contest_uid, priority, weight):
#     def _addTaskToQueues(self, task):
#     def _removeTaskFromQueues(self, task):
#     def _attachTaskToWorker(self, task, worker):
#     def addTask(self, env):
#     def delTask(self, task_id):
#     def _getNumberOfBlockedAnyCpuWorkers(self):
#     def _scheduleOnce(self):
#     def schedule(self):


# Path: sio/sioworkersd/scheduler/test_prioritizing.py
import random
import unittest
import six
from sio.sioworkersd.scheduler import prioritizing
from six.moves import range

            'concurrency': 4,
            'ram': 2048,
            'is_real_cpu': False,
        }

        scheduler = prioritizing.PrioritizingScheduler(
            WorkerManagerStub(vcpu_only_worker)
        )

        scheduler.addWorker(1)

        scheduler.updateContest(contest_uid=1, priority=10, weight=10)

        add_task_to_scheduler(scheduler, 1, is_real_cpu=False, ram=1024)
        add_task_to_scheduler(scheduler, 2, is_real_cpu=False, ram=512)
        add_task_to_scheduler(scheduler, 3, is_real_cpu=False, ram=1024)

        scheduled_tasks = scheduler.schedule()

        # Third task should be blocked.
        six.assertCountEqual(self, [(1, 1), (2, 1)], scheduled_tasks)

    def test_should_respect_concurrency_limits_when_assigning_vcpu_tasks(self):
        vcpu_only_worker = {
            'id': 1,
            'concurrency': 2,
            'ram': 8192,
            'is_real_cpu': False,
        }


        scheduler = prioritizing.PrioritizingScheduler(