FIX: macosx, always put timers on main thread #25553
Merged
+1
−1
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 main thread is the one that is running when started, so we should put all timers we control on that thread. Otherwise, we need to start and control runloops on the other threads which may or may not be started. This is particularly important for
draw_idle()
calls that may be sent from a separate thread where work was being done, but the draw should happen on the main thread still.closes #5675
To test, you can use the example from #5675 with some updates from other comments in there (save to file and run in interactive mode
python -i mac-threading-test.py
. Previously, the canvas would never be updated and freeze after the fact due to the extra thread waiting to have a runloop started and capture the draw events that were sent. There is a slight concern that we could hang the GUI event loop if we send too many timer events, but this seems to work just fine in practice here when I'm running this example I can change over to the pan tool and still move the canvas even while receiving the events.PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst