I am trying to build an AI chess bot, with a python back-end and React front-end. When I run it locally it works fine, but when deploying on Heroku for free, I get the following error message:
result = engine.play(board, chess.engine.Limit(time=0.1)) chess.engine.EngineTerminatedError: engine process died unexpectedly (exit code: 0)
The linux stockfish file works fine on Heroku bash.
This is my code:
import chess
import chess.engine
from flask import Flask
import os
import stat
import sys
app = Flask(__name__)
@app.route('/')
def index():
board = chess.Board()
if sys.platform == "linux":
os.chmod("./stockfish_20011801_x64", stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
engine = chess.engine.SimpleEngine.popen_uci("./stockfish_20011801_x64")
else:
engine = chess.engine.SimpleEngine.popen_uci("./stockfish_20011801_x64.exe")
result = engine.play(board, chess.engine.Limit(time=3))
board.push(result.move)
return board.fen()
Here are part of the logs:
DEBUG:chess.engine:<UciProtocol (pid=10)>: >> uciok
DEBUG:chess.engine:<UciProtocol (pid=10)>: << ucinewgame
DEBUG:chess.engine:<UciProtocol (pid=10)>: << isready
DEBUG:chess.engine:<UciProtocol (pid=10)>: Process exited
DEBUG:chess.engine:<UciProtocol (pid=10)>: Connection lost (exit code: 0, error: None)
chess.engine.EngineTerminatedError: engine process died unexpectedly (exit code: 0)
When I uninstalled eventlet it did work. I tried to uninstall it because it is very similar to asyncio, which is an dependency of python-chess.