Skip to content

fix(cli): ignore CancelledError in background task done callback (#839)#842

Open
rudi193-cmd wants to merge 1 commit into
basicmachines-co:mainfrom
rudi193-cmd:fix/task-cancelled-callback
Open

fix(cli): ignore CancelledError in background task done callback (#839)#842
rudi193-cmd wants to merge 1 commit into
basicmachines-co:mainfrom
rudi193-cmd:fix/task-cancelled-callback

Conversation

@rudi193-cmd
Copy link
Copy Markdown

Summary

After a successful basic-memory tool write-note, stderr could show an asyncio.CancelledError traceback even though exit code was 0 and stdout JSON was correct.

LocalTaskScheduler attaches _log_task_failure to background sync_entity_vectors tasks. On CLI teardown the task is cancelled; completed.result() raises CancelledError, which is a BaseException (not caught by except Exception).

Fix

  • Return early when completed.cancelled()
  • Explicitly ignore asyncio.CancelledError
  • Regression tests in tests/deps/test_task_failure_callback.py

Test plan

  • pytest tests/deps/test_task_failure_callback.py

Fixes #839

Made with Cursor

…icmachines-co#839)

CLI teardown cancels pending sync_entity_vectors tasks; _log_task_failure
treated that as an unhandled callback exception because CancelledError is a
BaseException. Skip cancelled tasks and add regression tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: rudi193-cmd <rudi193@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

[BUG] CLI write-note prints CancelledError traceback on stderr: _log_task_failure doesn't handle task cancellation on process exit

1 participant