FIX: Add macos timers to the main thread #27527
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR summary
The macos timers need to be explicitly added to the main runloop so the drawing takes place there. This causes issues if updating data from other threads and wanting the plot to update.
Fixed previously in: #25553
Which then had a regression via: #26022 which apparently uses a method that puts the timer onto the currently active thread rather than the main one. So, we need to explicitly add the timer to the main runloop.
I tried adding this as an interactive test, but couldn't get it to trigger the draws properly from the subprocess (not sure if it is because we need to set something up differently when running as
python -i
from a subprocess?). Any thoughts folks have for how to test this so we don't regress again would be welcome.Same example to manually test with. Save to file, and run with
python -i testfile.py
. I get a segfault currently trying to draw from a separate thread, and this updates as expected now.PR checklist