':return: A tuple containing a list of HostQueueEntry instances to be
used to run this Job, a string group name to suggest giving
to this job in the results database.'

def _choose_group_to_run(self, include_queue_entry):

    atomic_group = include_queue_entry.atomic_group
    chosen_entries = [include_queue_entry]
    if atomic_group:
        num_entries_wanted = atomic_group.max_number_of_machines
    else:
        num_entries_wanted = self.synch_count
    num_entries_wanted -= len(chosen_entries)
    if (num_entries_wanted > 0):
        where_clause = 'job_id    =    %s    AND    status    =    "Pending"    AND    id    !=    %s'
        pending_entries = list(HostQueueEntry.fetch(where=where_clause, params=(self.id, include_queue_entry.id)))
        def cmp_queue_entries_by_hostname(entry_a, entry_b):
            return Host.cmp_for_sort(entry_a.host, entry_b.host)
        pending_entries.sort(cmp=cmp_queue_entries_by_hostname)
        chosen_entries += pending_entries[:num_entries_wanted]
    if (len(chosen_entries) < self.synch_count):
        subject = 'Job    not    started,    too    few    chosen    entries'
        message = ('job    %s    got    less    than    %s    chosen    entries:    %s' % (self.id, self.synch_count, chosen_entries))
        logging.error(message)
        mail.manager.enqueue_admin(subject, message)
        return []
    group_name = include_queue_entry.get_group_name()
    self._assign_new_group(chosen_entries, group_name=group_name)
    return chosen_entries
