Skip to content

Commit c432586

Browse files
Copilotfsmosca
andcommitted
Fix RunEngine thread blocking on engine.play() after kill signal
When the analysis thread is interrupted via _kill.set(), if no bestmove was found yet (bm is None), RunEngine.run() falls through to engine.play(board, Limit(depth=None)) — an unconstrained synchronous call that blocks the thread indefinitely. This makes join() hang and freezes the GUI. Fix: skip the engine.play() fallback when _kill is set, and also make the move delay loop respect the kill signal. Agent-Logs-Url: https://github.com/fsmosca/Python-Easy-Chess-GUI/sessions/225e88fb-0a7d-479d-8208-22d1eb8867e0 Co-authored-by: fsmosca <22366935+fsmosca@users.noreply.github.com>
1 parent 90ab247 commit c432586

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

python_easy_chess_gui.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,13 +691,17 @@ def run(self):
691691
# Apply engine move delay if movetime is small
692692
if self.is_move_delay:
693693
while True:
694-
if time.perf_counter() - start_time >= self.move_delay_sec:
694+
if (self._kill.is_set()
695+
or time.perf_counter() - start_time
696+
>= self.move_delay_sec):
695697
break
696698
logging.info('Delay sending of best move {}'.format(self.bm))
697699
time.sleep(1.0)
698700

699701
# If bm is None, we will use engine.play()
700-
if self.bm is None:
702+
# Skip this fallback when the search was explicitly interrupted
703+
# to avoid blocking the thread with an unconstrained engine call.
704+
if self.bm is None and not self._kill.is_set():
701705
logging.info('bm is none, we will try engine,play().')
702706
try:
703707
result = self.engine.play(self.board, limit)

0 commit comments

Comments
 (0)