Title: CallbackRegistry should not silently drop duplicate callbacks · Issue #20210 · matplotlib/matplotlib · GitHub
Open Graph Title: CallbackRegistry should not silently drop duplicate callbacks · Issue #20210 · matplotlib/matplotlib
X Title: CallbackRegistry should not silently drop duplicate callbacks · Issue #20210 · matplotlib/matplotlib
Description: Bug report Bug summary Currently, if a same function is connected twice to the same signal and same callbackregisry, the second connection is silently dropped, per matplotlib/lib/matplotlib/cbook/__init__.py Lines 208 to 210 in b6a6414 p...
Open Graph Description: Bug report Bug summary Currently, if a same function is connected twice to the same signal and same callbackregisry, the second connection is silently dropped, per matplotlib/lib/matplotlib/cbook/_...
X Description: Bug report Bug summary Currently, if a same function is connected twice to the same signal and same callbackregisry, the second connection is silently dropped, per matplotlib/lib/matplotlib/cbook/_...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/20210
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"CallbackRegistry should not silently drop duplicate callbacks","articleBody":"\u003c!--To help us understand and resolve your issue, please fill out the form to the best of your ability.--\u003e\r\n\u003c!--You can feel free to delete the sections that do not apply.--\u003e\r\n\r\n### Bug report\r\n\r\n**Bug summary**\r\n\r\nCurrently, if a same function is connected twice to the same signal and same callbackregisry, the second connection is silently dropped, per https://github.com/matplotlib/matplotlib/blob/b6a6414522f20a1f1b458ebe296b178856662dda/lib/matplotlib/cbook/__init__.py#L208-L210\r\nThis seems not so nice and a bit surprising (as in https://github.com/matplotlib/matplotlib/issues/15785#issuecomment-838512093); we should deprecate that behavior and either\r\n- (preferred) just always perform the connection, even if duplicated; it's the user's job to keep track of duplicates if they want; or\r\n- (less preferred) add something like `keep_duplicates={None,True,False}` where None (default) raises an exception for duplicates, True keeps them, False drops them.\r\n\r\n\u003c!--A short 1-2 sentences that succinctly describes the bug--\u003e\r\n\r\n**Code for reproduction**\r\n\r\n\u003c!--A minimum code snippet required to reproduce the bug.\r\nPlease make sure to minimize the number of dependencies required, and provide\r\nany necessary plotted data.\r\nAvoid using threads, as Matplotlib is (explicitly) not thread-safe.--\u003e\r\n\r\n```python\r\nfor _ in range(2): gcf().canvas.mpl_connect(\"button_press_event\", print)\r\nshow()\r\n```\r\nand click on the canvas.\r\n\r\n**Actual outcome**\r\n\r\nThe event is printed once.\r\n\r\n**Expected outcome**\r\n\r\nThe event is printed twice.\r\n\r\n**Matplotlib version**\r\n\u003c!--Please specify your platform and versions of the relevant libraries you are using:--\u003e\r\n * Operating system: linux\r\n * Matplotlib version (`import matplotlib; print(matplotlib.__version__)`): HEAD (3.4.x+)\r\n * Matplotlib backend (`print(matplotlib.get_backend())`): any\r\n * Python version: 39\r\n * Jupyter version (if applicable): \r\n * Other libraries: \r\n\r\n\u003c!--Please tell us how you installed matplotlib and python e.g., from source, pip, conda--\u003e\r\n\u003c!--If you installed from conda, please specify which channel you used if not the default--\u003e\r\n\r\n","author":{"url":"https://github.com/anntzer","@type":"Person","name":"anntzer"},"datePublished":"2021-05-12T11:57:12.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":5},"url":"https://github.com/20210/matplotlib/issues/20210"}
| 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:3f6317f4-e890-1f9b-e77a-937fc57a81df |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CCCA:15C919:17E8E79:1FA8EF4:6A52BA7C |
| html-safe-nonce | dff081533bc3ab3f6c324852a0db92da2be51a10bef2f8bfb533df7344416e0e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQ0NBOjE1QzkxOToxN0U4RTc5OjFGQThFRjQ6NkE1MkJBN0MiLCJ2aXNpdG9yX2lkIjoiNDIzMTM4MTI5OTEwMzk3MTk2NCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 41e84bd8e9d04cb76e4be465a5f7537d400d101e9573fa022fdf70cf6c5be154 |
| hovercard-subject-tag | issue:890008596 |
| 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/20210/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d98048de699fcd88a649c496ab9309c94ca5d7b6c347264f8c3b759d3091e9e5/matplotlib/matplotlib/issues/20210 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d98048de699fcd88a649c496ab9309c94ca5d7b6c347264f8c3b759d3091e9e5/matplotlib/matplotlib/issues/20210 |
| og:image:alt | Bug report Bug summary Currently, if a same function is connected twice to the same signal and same callbackregisry, the second connection is silently dropped, per matplotlib/lib/matplotlib/cbook/_... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | anntzer |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width