def test2():
    job_source = Game_dispatcher()
    job_manager.run_jobs(job_source, 3, allow_mp=True)
    assert job_source.errors_seen == [
        "ValueError: invalid literal for int() with base 10: 'forcefailure4'\n"
        "traceback (most recent call last):\n"
        "  gomill_process_tests/test_job_manager.py:20 (run)\n"
        "failing line:\n"
        "int(\"forcefailure4\")\n"
    ]
    print "\nTEST PASSED\n"
示例#2
0
def test2():
    job_source = Game_dispatcher()
    job_manager.run_jobs(job_source, 3, allow_mp=True)
    assert job_source.errors_seen == [
        "ValueError: invalid literal for int() with base 10: 'forcefailure4'\n"
        "traceback (most recent call last):\n"
        "  gomill_process_tests/test_job_manager.py:20 (run)\n"
        "failing line:\n"
        "int(\"forcefailure4\")\n"
        ]
    print "\nTEST PASSED\n"
示例#3
0
    def run(self, max_games=None):
        """Run the competition.

        max_games -- int or None (maximum games to start in this run)

        Returns when max_games have been played in this run, when the
        Competition is over, or when a 'stop' command is received via the
        command file.

        """
        def now():
            return datetime.datetime.now().strftime("%Y-%m-%d %H:%M")

        def log_games_in_progress():
            try:
                msg = "games in progress were: %s" % (" ".join(
                    sorted(self.games_in_progress)))
            except Exception:
                pass
            self.log(msg)

        self._open_files()
        self.competition.set_event_logger(self.log)
        self.competition.set_history_logger(self.log_history)

        self._initialise_presenter()
        self._initialise_terminal_reader()

        allow_mp = (self.worker_count is not None)
        self.log("run started at %s with max_games %s" % (now(), max_games))
        if allow_mp:
            self.log("using %d worker processes" % self.worker_count)
        self.max_games_this_run = max_games
        self._update_display()
        try:
            job_manager.run_jobs(job_source=self,
                                 allow_mp=allow_mp,
                                 max_workers=self.worker_count,
                                 passed_exceptions=[
                                     RingmasterError, CompetitionError,
                                     RingmasterInternalError
                                 ])
        except KeyboardInterrupt:
            self.log("run interrupted at %s" % now())
            log_games_in_progress()
            raise
        except (RingmasterError, CompetitionError), e:
            self.log("run finished with error at %s\n%s" % (now(), e))
            log_games_in_progress()
            raise RingmasterError(e)
示例#4
0
    def run(self, max_games=None):
        """Run the competition.

        max_games -- int or None (maximum games to start in this run)

        Returns when max_games have been played in this run, when the
        Competition is over, or when a 'stop' command is received via the
        command file.

        """
        def now():
            return datetime.datetime.now().strftime("%Y-%m-%d %H:%M")

        def log_games_in_progress():
            try:
                msg = "games in progress were: %s" % (
                    " ".join(sorted(self.games_in_progress)))
            except Exception:
                pass
            self.log(msg)

        self._open_files()
        self.competition.set_event_logger(self.log)
        self.competition.set_history_logger(self.log_history)

        self._initialise_presenter()
        self._initialise_terminal_reader()

        allow_mp = (self.worker_count is not None)
        self.log("run started at %s with max_games %s" % (now(), max_games))
        if allow_mp:
            self.log("using %d worker processes" % self.worker_count)
        self.max_games_this_run = max_games
        self._update_display()
        try:
            job_manager.run_jobs(
                job_source=self,
                allow_mp=allow_mp, max_workers=self.worker_count,
                passed_exceptions=[RingmasterError, CompetitionError,
                                   RingmasterInternalError])
        except KeyboardInterrupt:
            self.log("run interrupted at %s" % now())
            log_games_in_progress()
            raise
        except (RingmasterError, CompetitionError), e:
            self.log("run finished with error at %s\n%s" % (now(), e))
            log_games_in_progress()
            raise RingmasterError(e)