0

我得到了:OSError: [Errno 24] Too many open filesstockfish 正在创建太多的进程。我该如何解决?

这是我的代码中导致错误的部分:

import chess.engine

def stockfish(board, time_limit = 0.1):
    engine = chess.engine.SimpleEngine.popen_uci("stockfish/stockfish_10_x64")
    result = engine.analyse(board, chess.engine.Limit(time=time_limit, depth=0))
    score = str(result["score"])
    if "#" in score:
        return 999*int(abs(int(score[1:]))/int(score[1:]))
    else:
        return int(score)

def stockfish_from_fen(fen, time_limit = 0.1):
    import chess
    board = chess.Board(fen)
    return stockfish(board, time_limit)

while True:
    print(stockfish_from_fen("8/8/8/5k2/8/3K4/2Q5/8 b - - 0 1"))

很多

4

0 回答 0