def test_start_filelock(mocker, default_conf, caplog) -> None:
    start_mock = MagicMock(side_effect=Timeout(HYPEROPT_LOCKFILE))
    mocker.patch('freqtrade.configuration.Configuration._load_config_file',
                 lambda *args, **kwargs: default_conf)
    mocker.patch('freqtrade.optimize.hyperopt.Hyperopt.start', start_mock)
    patch_exchange(mocker)

    args = ['--config', 'config.json', 'hyperopt', '--epochs', '5']
    args = get_args(args)
    start_hyperopt(args)
    assert log_has("Another running instance of freqtrade Hyperopt detected.",
                   caplog.record_tuples)
Beispiel #2
0
def test_start_filelock(mocker, default_conf, caplog) -> None:
    start_mock = MagicMock(
        side_effect=Timeout(Hyperopt.get_lock_filename(default_conf)))
    patched_configuration_load_config_file(mocker, default_conf)
    mocker.patch('freqtrade.optimize.hyperopt.Hyperopt.start', start_mock)
    patch_exchange(mocker)

    args = ['--config', 'config.json', 'hyperopt', '--epochs', '5']
    args = get_args(args)
    start_hyperopt(args)
    assert log_has("Another running instance of freqtrade Hyperopt detected.",
                   caplog)
Beispiel #3
0
    def acquire(self, timeout=None):
        time_started = time.time()
        while True:
            res = self.acquire_try_once(timeout)
            if res:
                return True

            if self.keep_alive_handler:
                try_fnc_rtt(lambda: self.keep_alive_handler())

            time_now = time.time()
            if timeout is not None and timeout < 0:
                time.sleep(0.01)
                continue
            if timeout is not None and timeout == 0:
                logger.info("Timeout, immediate")
                raise Timeout(self.path)
            if timeout is None and time_now - time_started > self.acquire_timeout:
                logger.info("Timeout, self.acquire_timeout")
                raise Timeout(self.path)
            if timeout is not None and timeout > 0 and time_now - time_started > timeout:
                logger.info("Timeout, defined")
                raise Timeout(self.path)
Beispiel #4
0
def test_start_filelock(mocker, hyperopt_conf, caplog) -> None:
    hyperopt_mock = MagicMock(
        side_effect=Timeout(Hyperopt.get_lock_filename(hyperopt_conf)))
    patched_configuration_load_config_file(mocker, hyperopt_conf)
    mocker.patch('freqtrade.optimize.hyperopt.Hyperopt.__init__',
                 hyperopt_mock)
    patch_exchange(mocker)

    args = [
        'hyperopt', '--config', 'config.json', '--hyperopt', 'DefaultHyperOpt',
        '--hyperopt-loss', 'SharpeHyperOptLossDaily', '--epochs', '5'
    ]
    pargs = get_args(args)
    start_hyperopt(pargs)
    assert log_has("Another running instance of freqtrade Hyperopt detected.",
                   caplog)
Beispiel #5
0
 def never_acquire(self, *arg, **kwargs):
     """Do not try to acquire, raise timeout"""
     raise Timeout(self)