From 39e3556d614a75574009c519f0d732d3c453ae3d Mon Sep 17 00:00:00 2001 From: Daniel Szoke Date: Wed, 25 Oct 2023 15:11:28 +0200 Subject: [PATCH] Patch eventlet under Sentry SDK (#2464) * Patch eventlet on Sentry SDK * Update sequence * Remove redundant stuff Co-authored-by: Sergey Shepelev * fix codestyle * Applied Black formatting to utils.py --------- Co-authored-by: Guilherme Scaranse Co-authored-by: Sergey Shepelev --- sentry_sdk/utils.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/utils.py b/sentry_sdk/utils.py index c811d2d2fe..22816e3d33 100644 --- a/sentry_sdk/utils.py +++ b/sentry_sdk/utils.py @@ -1159,9 +1159,18 @@ def _is_contextvars_broken(): pass try: + import greenlet # type: ignore from eventlet.patcher import is_monkey_patched # type: ignore - if is_monkey_patched("thread"): + greenlet_version = parse_version(greenlet.__version__) + + if greenlet_version is None: + logger.error( + "Internal error in Sentry SDK: Could not parse Greenlet version from greenlet.__version__." + ) + return False + + if is_monkey_patched("thread") and greenlet_version < (0, 5): return True except ImportError: pass