def do_work(self, actions_queue, returns_queue, control_queue=None):  # pragma: no cover
        """Main function of the worker.
        * Get checks
        * Launch new checks
        * Manage finished checks

        :param actions_queue: Global Queue Master->Slave
        :type actions_queue: Queue.Queue
        :param returns_queue: queue managed by manager
        :type returns_queue: Queue.Queue
        :return: None
        """
        # restore default signal handler for the workers:
        # signal.signal(signal.SIGTERM, signal.SIG_DFL)
        self.interrupted = False
        self.set_exit_handler()

        setproctitle("alignak-%s worker %s" % (self.loaded_into, self._id))

        timeout = 1.0
        self.checks = []
        self.t_each_loop = time.time()
        while True:
            begin = time.time()
            logger.debug("--- loop begin: %s", begin)

            # If we are dying (big problem!) we do not
            # take new jobs, we just finished the current one
            if not self.i_am_dying:
                # REF: doc/alignak-action-queues.png (3)
                self.get_new_checks(actions_queue, returns_queue)
                # REF: doc/alignak-action-queues.png (4)
                self.launch_new_checks()
            # REF: doc/alignak-action-queues.png (5)
            self.manage_finished_checks(returns_queue)

            logger.debug("loop middle, %d checks", len(self.checks))

            # Now get order from master, if any...
            if control_queue:
                try:
                    control_message = control_queue.get_nowait()
                    logger.info("[%s] Got a message: %s", self._id, control_message)
                    if control_message and control_message.get_type() == 'Die':
                        logger.info("[%s] The master said we must die... :(", self._id)
                        break
                except Full:
                    logger.warning("Worker control queue is full")
                except Empty:
                    pass
                except Exception as exp:  # pylint: disable=broad-except
                    logger.error("Exception when getting master orders: %s. ", str(exp))

            # Maybe someone asked us to die, if so, do it :)
            if self.interrupted:
                logger.info("I die because someone asked ;)")
                break

            # Look if we are dying, and if we finish all current checks
            # if so, we really die, our master poller will launch a new
            # worker because we were too weak to manage our job :(
            if not self.checks and self.i_am_dying:
                logger.warning("I die because I cannot do my job as I should "
                               "(too many open files?)... forgive me please.")
                break

            # Manage a possible time change (our avant will be change with the diff)
            diff = self.check_for_system_time_change()
            begin += diff
            logger.debug("loop check timechange: %s", diff)

            timeout -= time.time() - begin
            if timeout < 0:
                timeout = 1.0
            else:
                time.sleep(0.1)

            logger.debug("+++ loop end: timeout = %s, idle: %s, checks: %d, "
                         "actions (got: %d, launched: %d, finished: %d)",
                         timeout, self._idletime, len(self.checks),
                         self.actions_got, self.actions_launched, self.actions_finished)