Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError is thrown if async analysis is cancelled too soon #1116

Open
mooskagh opened this issue Oct 26, 2024 · 0 comments
Open

AssertionError is thrown if async analysis is cancelled too soon #1116

mooskagh opened this issue Oct 26, 2024 · 0 comments

Comments

@mooskagh
Copy link

I'm writing a website that listens to a pgn feed and runs an analysis of the current position in an asyncio task. When a new position comes, the analysis task is cancelled, and new task started.

If analysis is cancelled too soon (two updates come one after another), python-chess throws an AssertionError exception.

Traceback (most recent call last):
  File "/home/crem/dev/lczero-live/backend/analyzer.py", line 157, in _uci_worker_think
    with await self._engine.analysis(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/crem/dev/lczero-live/.venv/lib/python3.12/site-packages/chess/engine.py", line 1774, in analysis
    return await self.communicate(UciAnalysisCommand)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/crem/dev/lczero-live/.venv/lib/python3.12/site-packages/chess/engine.py", line 997, in communicate
    self.next_command.set_finished()
  File "/home/crem/dev/lczero-live/.venv/lib/python3.12/site-packages/chess/engine.py", line 1269, in set_finished
    assert self.state in [CommandState.ACTIVE, CommandState.CANCELLING], self.state
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: CommandState.NEW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant