Skip to content

fix: Catch BaseException in worker thread to prevent tracebacks on interruption#540

Open
szmania wants to merge 2 commits into
cecli-dev:v0.100.2from
szmania:cli-29-interruption-exception-take-5
Open

fix: Catch BaseException in worker thread to prevent tracebacks on interruption#540
szmania wants to merge 2 commits into
cecli-dev:v0.100.2from
szmania:cli-29-interruption-exception-take-5

Conversation

@szmania
Copy link
Copy Markdown

@szmania szmania commented May 29, 2026

Summary

Fixes an issue where KeyboardInterrupt exceptions during async completion calls would produce ugly tracebacks and potentially crash the TUI worker thread.

Changes

cecli/tui/worker.py

  • Consolidated exception handling in CoderWorker.run() to catch BaseException instead of only asyncio.CancelledError and RuntimeError. This ensures KeyboardInterrupt, SystemExit, and any other unexpected exceptions don't crash the worker thread.
  • Removed the now-redundant except KeyboardInterrupt block in _async_run() since the outer BaseException catch in run() already handles it.

cecli/models.py

  • Added except KeyboardInterrupt handler in the model's async completion loop to gracefully exit without a traceback when an interrupt occurs mid-request.

Related Issues

  • Jira: CLI-29
  • Previous attempts: cli-29-interruption-exception-take-1 through take-4

@szmania
Copy link
Copy Markdown
Author

szmania commented May 29, 2026

@dwash96 This PR is in draft and should remain so until at least 4 more days of testing have passed to confirm the interruption exception issue no longer occurs. Please do not merge until the testing window is complete.

@szmania szmania changed the base branch from main to v0.100.2 May 31, 2026 21:03
@szmania
Copy link
Copy Markdown
Author

szmania commented May 31, 2026

@dwash96 I've been using this for 3 days incessantly, seems to have fixed the issue. setting to ready for merge

@szmania szmania marked this pull request as ready for review May 31, 2026 21:04
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

Successfully merging this pull request may close these issues.

1 participant