py-stockfish / stockfish

Integrates the Stockfish chess engine with Python (Official fork)
https://py-stockfish.github.io/stockfish/
MIT License
30 stars 9 forks source link

Consuming remaining output of the stockfish popen process #47

Open johndoknjas opened 1 year ago

johndoknjas commented 1 year ago

After calling a function in models.py that uses self._read_line(), it'd be good if we could test that there's no remaining output left for the stockfish process. I've added a fixture in test_models.py that can be used to test the stockfish instance (after each test function finishes). So if there's a way to test that trying to call stockfish._read_line() will hang at that point (due to no output left over), that might be good.

Also, the current way we consume remaining output relies on having to know what the last line looks like (see self._discard_remaining_stdout_lines()). A more streamlined solution may be better. E.g., the top answer here could maybe be used, with a wait time of a millisecond?