Ejemplo n.º 1
0
    def get_supported_algos(cls):
        if cls._cached_ccminer_algos:
            return cls._cached_ccminer_algos

        proc = start_proc("/usr/local/bin/tpruvot-ccminer -h",
                          pipe_stdout=True)
        reading_algos = False
        supported_algos = set()

        for line in proc.stdout:
            line = line.strip()

            if line.split(b" ")[0] == b"-d,":
                break

            if reading_algos:
                supported_algos.add(line.split(b" ")[0].decode("UTF-8"))

            if line.split(b" ")[0] == b"-a,":
                reading_algos = True

        term_proc(proc)

        cls._cached_ccminer_algos = supported_algos
        return supported_algos
Ejemplo n.º 2
0
    def stop_mining_and_return_when_stopped(self):
        LOG.debug("Terminating ccminer (%s)...", self.algo)
        term_proc(self.miner_proc)

        LOG.debug("Terminating logging thread for ccminer (%s)...", self.algo)
        self.logger_thread.join()
        self.miner_proc = None
        self.logger_thread = None
Ejemplo n.º 3
0
    def _return_when_miner_is_using_gpu(self):
        assert self.miner_proc and self.miner_proc.poll(
        ) is None, "Process is not running"

        checker = start_proc("nvidia-smi pmon", pipe_stdout=True)

        for line in checker.stdout:
            if str(self.miner_proc.pid).encode('utf-8') in line:
                break

        term_proc(checker)
Ejemplo n.º 4
0
    def test_term_proc_term_disabled(self):
        logging.getLogger().setLevel(logging.ERROR)

        def trap():
            signal.signal(signal.SIGTERM, signal.SIG_IGN)

        proc = start_proc("sleep 1000", preexec_fn=trap)
        self.assertIsNone(proc.poll())
        term_proc(proc, term_wait_time=0.1)
        self.assertEqual(proc.poll(), -9)
        logging.getLogger().setLevel(logging.WARNING)
Ejemplo n.º 5
0
    def benchmark(self):
        cmd = self._get_run_cmd(self.path_to_exec,
                                self.algo,
                                "",
                                "",
                                "",
                                "",
                                kwargs={
                                    "--benchmark": "",
                                    "--no-color": ""
                                })
        LOG.debug("Benchmarking \033[92m%s\033[0m...", self.algo)
        cache_key = "BENCHHR%s" % (cmd)
        cached_benchmark = MinerStore.get(cache_key)
        if cached_benchmark:
            b = Rate(cached_benchmark)
            LOG.debug("Benchmark found in cache: %s!", b)
            return b

        LOG.info("Benchmark not found for \033[92m%s\033[0m. Benchmarking...",
                 self.algo)

        bench_proc = start_proc(cmd, pipe_stdout=True)
        bm = Benchmarker()

        for line in bench_proc.stdout:
            line = line.strip().decode("UTF-8")

            if "Total:" in line:
                r = Rate(line.split(":")[-1].strip())
                bm.add_rate(r)

                final_hashrate = bm.get_benchmark()
                if final_hashrate:
                    break

        term_proc(bench_proc)

        MinerStore.set(cache_key, str(final_hashrate))
        LOG.info("Benchmark found: %s!", final_hashrate)

        return final_hashrate
Ejemplo n.º 6
0
 def test_term_proc_already_termed(self):
     proc = start_proc("sleep 1000")
     self.assertIsNone(proc.poll())
     term_proc(proc)
     self.assertEqual(proc.poll(), -15)
     term_proc(proc)