Time out Stockfish process exit so finished self-play games can't wedge in the store
DisposeAsync awaited WaitForExitAsync with no timeout; a Stockfish process that doesn't exit on "quit" blocked GameStore's removal task forever, leaving the finished game stuck in the store and cluttering the live-watch list indefinitely. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018CmAti1baCjidbJM2HeJfk
This commit is contained in:
@@ -100,11 +100,26 @@ public sealed class Stockfish : IChessEngine
|
|||||||
if (line == token) break;
|
if (line == token) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If Stockfish doesn't exit on "quit" (crashed, zombie, ignores stdin close), don't hang
|
||||||
|
// here forever — that would block GameStore's removal task and leave the finished game
|
||||||
|
// stuck in the store, cluttering the watch page indefinitely.
|
||||||
|
private static readonly TimeSpan _exitTimeout = TimeSpan.FromSeconds(5);
|
||||||
|
|
||||||
public async ValueTask DisposeAsync()
|
public async ValueTask DisposeAsync()
|
||||||
{
|
{
|
||||||
Send("quit");
|
Send("quit");
|
||||||
_stdin.Close();
|
_stdin.Close();
|
||||||
await _p.WaitForExitAsync();
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _p.WaitForExitAsync().WaitAsync(_exitTimeout);
|
||||||
|
}
|
||||||
|
catch (TimeoutException)
|
||||||
|
{
|
||||||
|
if (!_p.HasExited)
|
||||||
|
_p.Kill(entireProcessTree: true);
|
||||||
|
}
|
||||||
|
|
||||||
_p.Dispose();
|
_p.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user