Bugfix: Cancel Scheduled Dashboard Updates#105
Bugfix: Cancel Scheduled Dashboard Updates#105danielegelhoff13 wants to merge 9 commits intodevelopfrom
Conversation
…oard updates that are scheduled
|
After running a hardware test with all subsystems on, I will open this PR for review/merge. |
| return "break" | ||
|
|
||
| """Esnure that quit_app is called when the window is closed, not just when Ctrl+Q is pressed.""" | ||
| root.protocol("WM_DELETE_WINDOW", quit_app) |
There was a problem hiding this comment.
Here is the modification of quit behavior. When the window is closed, the same pop-up will appear saying "Do you want to quit?", and dashboard.py's cleanup() function will be invoked.
… after_id before trying to cancel an event.
|
Testing finished, this PR is ready for review and merge. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 864c11c10c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # Schedule next update | ||
| if self.driver: | ||
| self.parent.after(self.update_interval, self.update_data) | ||
| self.after_id = self.parent.after(self.update_interval, self.update_data) |
There was a problem hiding this comment.
Cancel all pending interlock timers on shutdown
This change records only one timer handle in self.after_id, but InterlocksSubsystem can still schedule other after() callbacks outside this tracked assignment (e.g., startup scheduling and the status is None retry path). In those cases, cancel_updates() will cancel only the last stored handle, leaving an untracked callback that can run after Tk teardown and continue producing shutdown-time after/invalid-command errors. Route all scheduling through a single tracked handle (or track a set of handles) so cleanup can reliably cancel every pending callback.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
This was issue; callbacks were being scheduled in 2 places in interlocks.py, but both were scheduling callbacks to the same update_data() function. So I defined _schedule_update() that only allows one callback to be scheduled at a time, preserving behavior and removing the possibility that 2 would exist at once, and not be cleanly cancelled.
Commit 9328a1e fixed this issue.
…nction, only allowing one callback of the update_data function to be scheduled.
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
The cancel_updates() method in interlocks.py sets after_id=None after cancelling. In cathode_heating.py and oil_system.py you don't set after_id=None in the cancel_updates() method. This isn't a bug because this is only called on exit so it shouldn't matter. But, for the sake of consistency you might consider looking into this. |
… after_id to None. Not required as cancel_updates() is only called once, but more rigorous.
Thanks Mathom, good catch. I fixed this in commit 51af636. The way that I also added a note to |
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Co-authored-by: sbasu107 <40325803+sbasu107@users.noreply.github.com>
Resolved conflicts in: - main.py: kept both 'KnobBox' and 'BeamPulse' in SUBSYSTEMS list - dashboard.py: kept ports_after_id from #105 + toggle images and BeamPulse subsystem init from BCON-lite - subsystem/cathode_heating/cathode_heating.py: kept HEAD's LUT-based logic (from #90) plus BCON-lite's turn_off_all_beams and set_target_current additions Co-authored-by: sbasu107 <40325803+sbasu107@users.noreply.github.com>
Description
This PR is targeted bugfix to remove printed console errors of the form:
These errors come from scheduled Tkinter Dashboard updates that are not cancelled when the app is quit, and so try to modify the Dashboard which no longer exists.
Additionally, this PR fixes a bug where the Dashboard's cleanup path was not invoked by just clicking the 'X' in the top right corner of the screen. Now, both Ctrl+Q and clicking the 'X' will trigger the correct Dashboard cleanup and shutdown path.
Summary of the Fix
Each subsystem file that uses Tkinter's after() function to schedule a Dashboard update in the future has been modified:
In each subsystem, a
cancel_updates()function has been defined and is called bycleanup()indashboard.py. Additionally indashboard.py, scheduled COM port checks are canceled.Tests Run
A full hardware test was run with all subsystems on 4/15/2026. The result was a success, and is documented here:
https://docs.google.com/document/d/1l9kT7njyEyAE3uNlWtzscGo2fp0MtTuWE9y5YJYrxlM/edit?tab=t.0 (on page 3)