Title: [MNT]: Event loop and timer consistency · Issue #32352 · matplotlib/matplotlib · GitHub
Open Graph Title: [MNT]: Event loop and timer consistency · Issue #32352 · matplotlib/matplotlib
X Title: [MNT]: Event loop and timer consistency · Issue #32352 · matplotlib/matplotlib
Description: Summary Right now, our methods related to event loops and timers have inconsistent behavior across interactive backends. When called on a worker thread, or when called in a specific order, these methods will often raise internal errors f...
Open Graph Description: Summary Right now, our methods related to event loops and timers have inconsistent behavior across interactive backends. When called on a worker thread, or when called in a specific order, these me...
X Description: Summary Right now, our methods related to event loops and timers have inconsistent behavior across interactive backends. When called on a worker thread, or when called in a specific order, these me...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/32352
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[MNT]: Event loop and timer consistency","articleBody":"### Summary\n\nRight now, our methods related to event loops and timers have inconsistent behavior across interactive backends. When called on a worker thread, or when called in a specific order, these methods will often raise internal errors from the wrapped GUI framework. In several cases, they will crash the process entirely.\n\nThe exact behavior can vary depending on platform. For example, `pyplot.show()` on a worker thread crashes in GTK+macOS, but works in GTK+Linux as long as you are **very** careful.\n\n### Proposed fix\n\nI propose that we unify the behavior across all interactive backends by raising an error when the following are called on a worker thread:\n\n`plt.show()`\n`FigureCanvas.start_event_loop()`\n`FigureCanvas.stop_event_loop()`\n`FigureCanvas.flush_events()`\n`FigureCanvas.new_timer()`\nAny method of `Timer` (*note: backends could still use Timers internally as needed*)\n\nAdditionally, for consistency:\n\n- `plt.show()` and `FigureCanvas.start_event_loop()` should raise an error if an event loop is already running - this matches the existing behavior of most backends.\n- `FigureCanvas.stop_event_loop()` should stop the event loop if it is running, regardless of how that event loop was started. If an event loop isn't running, it should simply return (the existing behavior of most backends).\n- All of the changes in #29062. I'm still auditing Timer behavior across backends - I believe that there are cases that this PR doesn't yet cover.\n\nFor now, we could add a deprecation message if the behavior doesn't already raise or crash. For behavior that currently crashes, I'm not sure of our policy. Would we print a deprecation message and then crash? Or would we raise an error now without a deprecation cycle?\n\nRelated issues: #31858, #31968","author":{"url":"https://github.com/iccir","@type":"Person","name":"iccir"},"datePublished":"2026-09-15T03:55:21Z","url":"https://github.com/matplotlib/matplotlib/issues/32352"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:669a37bd-77ca-0eda-f32f-2c24399996e7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C12E:1D2D33:F7EF3E:149BDA2:6B064EE6 |
| html-safe-nonce | 8f512a835d8161eca946098fc150df45033aac4ffd6e0098220791ddeadf55ff |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTJFOjFEMkQzMzpGN0VGM0U6MTQ5QkRBMjo2QjA2NEVFNiIsInZpc2l0b3JfaWQiOiI4NDA0NTYxNzQ4MDEwODgwNzQyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c4a2268dcafdcad9632c6f9f427f8cde11b6f38b67123297000d724695549c3f |
| hovercard-subject-tag | issue:5457292761 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/32352/issue_layout |
| twitter:image | https://opengraph.githubassets.com/dac6a1e1d41a5818fa6b0feb516677152fdae249df385ee01be53fbe7f36a07f/matplotlib/matplotlib/issues/32352 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dac6a1e1d41a5818fa6b0feb516677152fdae249df385ee01be53fbe7f36a07f/matplotlib/matplotlib/issues/32352 |
| og:image:alt | Summary Right now, our methods related to event loops and timers have inconsistent behavior across interactive backends. When called on a worker thread, or when called in a specific order, these me... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | iccir |
| hostname | github.com |
| expected-hostname | github.com |
| None | 772b6997ca4daa0428dd49a25d76052e765555ae560fe9c88517eb828bbd861e |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f1f9a08f7c769a37f1dfc18ad43d463c222a7eea |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width