'Select task to fetch & process'

def _check_select(self):

    while self._send_buffer:
        _task = self._send_buffer.pop()
        try:
            self.send_task(_task, False)
        except Queue.Full:
            self._send_buffer.append(_task)
            break
    if self.out_queue.full():
        return {}
    taskids = []
    cnt = 0
    cnt_dict = dict()
    limit = self.LOOP_LIMIT
    for project in itervalues(self.projects):
        if (not project.active):
            continue
        if project.paused:
            continue
        if project.waiting_get_info:
            continue
        if (cnt >= limit):
            break
        task_queue = project.task_queue
        task_queue.check_update()
        project_cnt = 0
        while ((cnt < limit) and (project_cnt < (limit / 10))):
            taskid = task_queue.get()
            if (not taskid):
                break
            taskids.append((project.name, taskid))
            if (taskid != 'on_finished'):
                project_cnt += 1
            cnt += 1
        cnt_dict[project.name] = project_cnt
        if project_cnt:
            project._selected_tasks = True
            project._send_finished_event_wait = 0
        if ((not project_cnt) and (len(task_queue) == 0) and project._selected_tasks):
            if (project._send_finished_event_wait < self.FAIL_PAUSE_NUM):
                project._send_finished_event_wait += 1
            else:
                project._selected_tasks = False
                project._send_finished_event_wait = 0
                self._postpone_request.append({'project': project.name, 'taskid': 'on_finished', 'url': 'data:,on_finished', 'process': {'callback': 'on_finished'}, 'schedule': {'age': 0, 'priority': 9, 'force_update': True}})
    for (project, taskid) in taskids:
        self._load_put_task(project, taskid)
    return cnt_dict
