Run one cycle of the main loop.

        If the log child has died, restart it.  If any of the worker
        children have died, collect their status codes and remove them
        from the child set.  If there is a worker slot available, start
        exactly one child.

        :param bool can_start_more: Allowed to start a child?
        :return:  Time to wait before calling this function again

def do_some_work(self, can_start_more):
        '''Run one cycle of the main loop.

        If the log child has died, restart it.  If any of the worker
        children have died, collect their status codes and remove them
        from the child set.  If there is a worker slot available, start
        exactly one child.

        :param bool can_start_more: Allowed to start a child?
        :return:  Time to wait before calling this function again

        '''
        any_happy_children = False
        any_sad_children = False
        any_bored_children = False

        self.debug('loop', 'starting work loop, can_start_more={0!r}'
                   .format(can_start_more))

        # See if anyone has died
        while True:
            try:
                pid, status = os.waitpid(-1, os.WNOHANG)
            except OSError, e:
                if e.errno == errno.ECHILD:
                    # No children at all
                    pid = 0
                else:
                    raise
            if pid == 0:
                break
            elif pid == self.log_child:
                self.debug('children',
                           'log child with pid {0} exited'.format(pid))
                self.start_log_child()
            elif pid in self.children:
                self.children.remove(pid)
                if os.WIFEXITED(status):
                    code = os.WEXITSTATUS(status)
                    self.debug('children',
                               'worker {0} exited with code {1}'
                               .format(pid, code))
                    if code == SingleWorker.EXIT_SUCCESS:
                        any_happy_children = True
                    elif code == SingleWorker.EXIT_EXCEPTION:
                        self.log(logging.WARNING,
                                 'child {0} reported failure'.format(pid))
                        any_sad_children = True
                    elif code == SingleWorker.EXIT_BORED:
                        any_bored_children = True
                    else:
                        self.log(logging.WARNING,
                                 'child {0} had odd exit code {1}'
                                 .format(pid, code))
                elif os.WIFSIGNALED(status):
                    self.log(logging.WARNING,
                             'child {0} exited with signal {1}'
                             .format(pid, os.WTERMSIG(status)))
                    any_sad_children = True
                else:
                    self.log(logging.WARNING,
                             'child {0} went away with unknown status {1}'
                             .format(pid, status))
                    any_sad_children = True
            else:
                self.log(logging.WARNING,
                         'child {0} exited, but we don\'t recognize it'
                         .format(pid))

        # ...what next?
        # (Don't log anything here; either we logged a WARNING message
        # above when things went badly, or we're in a very normal flow
        # and don't want to spam the log)
        if any_sad_children:
            self.debug('loop', 'exit work loop with sad child')
            return self.poll_interval

        if any_bored_children:
            self.debug('loop', 'exit work loop with no work')
            return self.poll_interval

        # This means we get to start a child, maybe.
        if can_start_more and len(self.children) < self.num_workers:
            pid = os.fork()
            if pid == 0:
                # We are the child
                self.clear_signal_handlers()
                if self.log_fd:
                    os.close(self.log_fd)
                LoopWorker.as_child(yakonfig.get_global_config(),
                                    parent=self.worker_id)
                # This should never return, but just in case
                sys.exit(SingleWorker.EXIT_EXCEPTION)
            else:
                # We are the parent
                self.debug('children', 'new worker with pid {0}'.format(pid))
                self.children.add(pid)
                self.debug('loop', 'exit work loop with a new worker')
                return self.spawn_interval

        # Absolutely nothing is happening; which means we have all
        # of our potential workers and they're doing work
        self.debug('loop', 'exit work loop with full system')
        return self.poll_interval