stable/scripts/start-hyperopt-worker.py

29 lines
662 B
Python
Raw Normal View History

2017-11-25 14:40:19 +00:00
#!/usr/bin/env python3
import multiprocessing
import os
import subprocess
2018-03-23 23:44:37 +00:00
2017-11-25 14:40:19 +00:00
PROC_COUNT = multiprocessing.cpu_count() - 1
DB_NAME = 'freqtrade_hyperopt'
WORK_DIR = os.path.join(
os.path.sep,
os.path.abspath(os.path.dirname(__file__)),
'..', '.hyperopt', 'worker'
)
if not os.path.exists(WORK_DIR):
os.makedirs(WORK_DIR)
# Spawn workers
command = [
'hyperopt-mongo-worker',
'--mongo=127.0.0.1:1234/{}'.format(DB_NAME),
'--poll-interval=0.1',
'--workdir={}'.format(WORK_DIR),
2018-03-24 01:33:03 +00:00
'--reserve-timeout=900',
2017-11-25 14:40:19 +00:00
]
2018-03-23 23:44:37 +00:00
processes = [subprocess.Popen(command) for i in range(PROC_COUNT)]
# Join all workers
for proc in processes:
proc.wait()