Skip to content

DisconnectedError handling#802

Open
ArisMorgens wants to merge 5 commits intocflib2from
Aris/cflib2/DisconnectedError
Open

DisconnectedError handling#802
ArisMorgens wants to merge 5 commits intocflib2from
Aris/cflib2/DisconnectedError

Conversation

@ArisMorgens
Copy link
Copy Markdown
Member

@ArisMorgens ArisMorgens commented Mar 25, 2026

This PR adds DisconnectedError handling for 3 features in the Flight tab (battery, pose, and motors). In all 3, the while True loop has no except, so when stream.next() raises DisconnectedError on disconnect, we get an error in the terminal.

It also fixes the annotations in main.py, pose_logger.py, and FlightTab.py, to pass pre-commit checks.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves disconnect robustness in the UI by preventing DisconnectedError exceptions from bubbling out of long-running telemetry streams (battery, pose, motor logging) and updates type annotations to satisfy pre-commit linting.

Changes:

  • Add DisconnectedError handling to streaming loops for battery, pose, and motor telemetry to avoid terminal errors on disconnect.
  • Add from __future__ import annotations and expand/adjust function and method type annotations in affected UI modules.
  • Introduce/standardize relevant type imports (e.g., Crazyflie, InputReaderInterface, Callable/Coroutine/Future).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/cfclient/ui/tabs/FlightTab.py Adds DisconnectedError handling for motor telemetry streaming and adds extensive method annotations.
src/cfclient/ui/pose_logger.py Adds DisconnectedError handling for pose streaming and adds/adjusts type annotations.
src/cfclient/ui/main.py Adds DisconnectedError handling for battery streaming and improves type annotations for commander pipeline and input-device UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ArisMorgens ArisMorgens changed the title DisconnectionError handling DisconnectedError handling Mar 26, 2026
Copy link
Copy Markdown
Member

@gemenerik gemenerik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find! The DisconnectedError on disconnect tracebacks were ugly!

We already had code in _task_done_callback that was supposed to catch DisconnectedError for all create_task coroutines, and it did catch them (preventing os._exit), but QtAsyncio still prints the traceback before the done callback runs, so they still showed up in the terminal. Rather than having to add except DisconnectedError: pass in every streaming coroutine, I've made a PR into your branch that wraps coroutines in create_task so DisconnectedError is caught before PySide6 can see it. The rest of your PR (annotations, setup-inside-try, disconnect log message) is unaffected. See #806

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.

3 participants