Title: Support concurrent.future · Issue #2614 · getsentry/sentry-python · GitHub
Open Graph Title: Support concurrent.future · Issue #2614 · getsentry/sentry-python
X Title: Support concurrent.future · Issue #2614 · getsentry/sentry-python
Description: Problem Statement When using Sentry with ThreadPoolExecutor, I couldn't automatically capture errors like in this issue. I think ThreadPoolExecutor use this run method. def run(self): if not self.future.set_running_or_notify_cancel(): re...
Open Graph Description: Problem Statement When using Sentry with ThreadPoolExecutor, I couldn't automatically capture errors like in this issue. I think ThreadPoolExecutor use this run method. def run(self): if not self.f...
X Description: Problem Statement When using Sentry with ThreadPoolExecutor, I couldn't automatically capture errors like in this issue. I think ThreadPoolExecutor use this run method. def run(self): if not se...
Opengraph URL: https://github.com/getsentry/sentry-python/issues/2614
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support concurrent.future","articleBody":"### Problem Statement\n\nWhen using Sentry with ThreadPoolExecutor, I couldn't automatically capture errors like in this [issue](https://github.com/getsentry/sentry-python/issues/1234).\r\n\r\nI think ThreadPoolExecutor use [this run method](https://github.com/python/cpython/blob/723f4d66982e4d2c54f8e874d6084ab7b2ff5833/Lib/concurrent/futures/thread.py#L53). \r\n```\r\n def run(self):\r\n if not self.future.set_running_or_notify_cancel():\r\n return\r\n try:\r\n result = self.fn(*self.args, **self.kwargs)\r\n except BaseException as exc:\r\n self.future.set_exception(exc)\r\n # Break a reference cycle with the exception 'exc'\r\n self = None\r\n else:\r\n self.future.set_result(result)\r\n```\r\n\r\n\n\n### Solution Brainstorm\n\nIn future.thread, it catches BaseException and handles it by using future.set_exception.\r\nTherefore, I am planning to create FutureIntegration to patch Future.set_exception so that Sentry can handle it.\r\n\r\nlike this.\r\n\r\n```\r\n def setup_once():\r\n from concurrent.futures import Future\r\n from concurrent.futures._base import CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED, InvalidStateError\r\n\r\n def sentry_set_exception(self, exception):\r\n with self._condition:\r\n if self._state in {CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED}:\r\n raise InvalidStateError('{}: {!r}'.format(self._state, self))\r\n self._exception = exception\r\n self._state = FINISHED\r\n for waiter in self._waiters:\r\n waiter.add_exception(self)\r\n self._condition.notify_all()\r\n self._invoke_callbacks()\r\n\r\n _capture_exception()\r\n\r\n Future.set_exception = sentry_set_exception\r\n```\r\n\r\n\r\nI've tested this process in my local environment and confirmed that it works well. Would it be okay for me to contribute in this way?","author":{"url":"https://github.com/wonkajin","@type":"Person","name":"wonkajin"},"datePublished":"2023-12-21T13:46:39Z","url":"https://github.com/getsentry/sentry-python/issues/2614"}
| 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:d5639bb3-9c5f-3822-303b-41ed0f030b1f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9DA0:29E0EC:479E7D:60431D:6B008E23 |
| html-safe-nonce | e7bbf7aed5d19f165b7d0f2f1132734fab1c02daf776e8144f928275a46b9b27 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5REEwOjI5RTBFQzo0NzlFN0Q6NjA0MzFEOjZCMDA4RTIzIiwidmlzaXRvcl9pZCI6IjQ0NTUwMzg2MjQzODMxNDM0NTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 47dd6c52bd5100990e5a82176124ae8f6671c0d0c352792f5d3b74223388111c |
| hovercard-subject-tag | issue:2052454981 |
| 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/getsentry/sentry-python/2614/issue_layout |
| twitter:image | https://opengraph.githubassets.com/afcf51c9d9fae2204883af9c4bf67559e0235be11ec9d74932cdedbe6c69af15/getsentry/sentry-python/issues/2614 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/afcf51c9d9fae2204883af9c4bf67559e0235be11ec9d74932cdedbe6c69af15/getsentry/sentry-python/issues/2614 |
| og:image:alt | Problem Statement When using Sentry with ThreadPoolExecutor, I couldn't automatically capture errors like in this issue. I think ThreadPoolExecutor use this run method. def run(self): if not self.f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wonkajin |
| hostname | github.com |
| expected-hostname | github.com |
| None | c710a5cb5c47be60abfe6e8410436d409906979dbed614ef09f29c60f5535b08 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-python git https://github.com/getsentry/sentry-python.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 137814779 |
| octolytics-dimension-repository_nwo | getsentry/sentry-python |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 137814779 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-python |
| 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 | be616a2a6ec1c609d6e002896dff5352d5c5f28b |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width