diff --git a/ddtrace/bootstrap/sitecustomize.py b/ddtrace/bootstrap/sitecustomize.py index b35419d6648..6c689a5262e 100644 --- a/ddtrace/bootstrap/sitecustomize.py +++ b/ddtrace/bootstrap/sitecustomize.py @@ -109,6 +109,7 @@ def drop(module_name): "concurrent", "typing", "re", # referenced by the typing module + "sre_constants", # imported by re at runtime "logging", "attr", "google.protobuf", # the upb backend in >= 4.21 does not like being unloaded diff --git a/releasenotes/notes/fix-re-unload-8770a3d497234243.yaml b/releasenotes/notes/fix-re-unload-8770a3d497234243.yaml new file mode 100644 index 00000000000..ae19172ad65 --- /dev/null +++ b/releasenotes/notes/fix-re-unload-8770a3d497234243.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixed a bug that caused applications using gevent and cassandra to fail to + start with the ddtrace-run command. diff --git a/tests/commands/test_runner.py b/tests/commands/test_runner.py index 8e34641a3ef..47124f30385 100644 --- a/tests/commands/test_runner.py +++ b/tests/commands/test_runner.py @@ -468,3 +468,16 @@ def test_no_args(): p.wait() assert p.returncode == 1 assert six.b("usage:") in p.stdout.read() + + +@pytest.mark.subprocess(ddtrace_run=True, env=dict(DD_UNLOAD_MODULES_FROM_SITECUSTOMIZE="1")) +def test_ddtrace_re_module(): + import re + + re.Scanner( + ( + ("frozen", None), + (r"[a-zA-Z0-9_]+", lambda s, t: t), + (r"[\s,<>]", None), + ) + )