Example #1
0
    def test_queue_order_is_stable(self):
        cmd_queue = cmds.CommandPriorityQueue()
        stop_cmds = [cmds.StopCmd() for _ in range(100)]
        for cmd in stop_cmds:
            cmd_queue.put_nowait(cmd)

        for expected_cmd in stop_cmds:
            assert expected_cmd is cmd_queue.get_nowait()
Example #2
0
    def test_stop_command_has_higher_priorityj(self):
        cmd_queue = cmds.CommandPriorityQueue()
        stop_cmd = cmds.StopCmd()
        cmd_queue.put_nowait(cmds.ResumeCmd())
        cmd_queue.put_nowait(stop_cmd)
        cmd_queue.put_nowait(cmds.PauseCmd())

        received_cmd = cmd_queue.get_nowait()
        assert stop_cmd is received_cmd
Example #3
0
    def shutdown(self) -> None:
        logger.debug("Shutting down...")

        stop_cmd = commands.StopCmd()
        self._supervisor.send_command(stop_cmd.awaitable)
        stop_cmd.awaitable.wait()

        self._supervisor_thread.join()

        logger.debug("Shutdown complete")
Example #4
0
 def worker_thread(self, supervisor):
     t = threading.Thread(target=supervisor.run)
     t.start()
     yield t
     supervisor.send_command(commands.StopCmd())
     t.join()