def run_chiboard(self):
pass
import subprocess
from chi import board
from chi.board import CHIBOARD_HOME, MAGIC_PORT
port = None
start = False
cbc = join(CHIBOARD_HOME, CONFIG_NAME)
if os.path.isfile(cbc):
with open(cbc) as f:
import fcntl
try:
fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
start = True
fcntl.flock(f, fcntl.LOCK_UN)
except (BlockingIOError, OSError): # chiboard is running
try:
data = json.load(f)
port = data.get('port')
except json.JSONDecodeError:
port = None
else:
start = True
if start:
from chi.board import main
chiboard = main.__file__
subprocess.check_call([sys.executable, chiboard, '--port', str(MAGIC_PORT), '--daemon'])
port = MAGIC_PORT
if port is None:
logger.warning('chiboard seems to be running but port could not be read from its config')
else:
logger.info(f"{self.f.__name__} started. Check progress at http://localhost:{port}/exp/#/local{self.logdir}")
评论列表
文章目录