Skip to content

Commit 224e897

Browse files
committed
update
1 parent 4b02c9d commit 224e897

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

ddtrace/internal/_unpatched.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,15 @@
33
from builtins import open as unpatched_open # noqa
44
from json import loads as unpatched_json_loads # noqa
55

6-
# Acquire references to threading and gc, then remove them from sys.modules.
7-
# Some parts of the library (e.g. the profiler) might be enabled programmatically
8-
# and patch the threading and gc modules. We store references to the original
9-
# modules here to allow ddtrace internal modules to access the right versions of
10-
# the modules.
6+
# Acquire a reference to the threading module. Some parts of the library (e.g.
7+
# the profiler) might be enabled programmatically and therefore might end up
8+
# getting a reference to the tracee's threading module. By storing a reference
9+
# to the threading module used by ddtrace here, we make it easy for those parts
10+
# to get a reference to the right threading module.
11+
import threading as _threading # noqa
12+
import gc as _gc # noqa
1113

12-
import gc # noqa
1314
import sys
14-
import threading # noqa
15-
16-
_threading = threading
17-
_gc = gc
18-
19-
sys.modules.pop("threading", None)
20-
sys.modules.pop("gc", None)
2115

2216
previous_loaded_modules = frozenset(sys.modules.keys())
2317
from subprocess import Popen as unpatched_Popen # noqa # nosec B404

tests/profiling_v2/collector/test_threading.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ def test_patch(
111111

112112

113113
@pytest.mark.subprocess(
114-
env=dict(WRAPT_DISABLE_EXTENSIONS="True", DD_PROFILING_FILE_PATH=__file__, DD_PROFILING_ENABLED="1"),
115-
ddtrace_run=True,
114+
env=dict(WRAPT_DISABLE_EXTENSIONS="True", DD_PROFILING_FILE_PATH=__file__),
116115
)
117116
def test_wrapt_disable_extensions() -> None:
118117
import os
@@ -361,7 +360,7 @@ def validate_and_cleanup() -> None:
361360
validate_and_cleanup()
362361

363362

364-
@pytest.mark.subprocess(env=dict(DD_PROFILING_ENABLE_ASSERTS="true", DD_PROFILING_ENABLED="1"), ddtrace_run=True)
363+
@pytest.mark.subprocess(env=dict(DD_PROFILING_ENABLE_ASSERTS="true"))
365364
def test_assertion_error_raised_with_enable_asserts():
366365
"""Ensure that AssertionError is propagated when config.enable_asserts=True."""
367366
import threading
@@ -388,7 +387,7 @@ def test_assertion_error_raised_with_enable_asserts():
388387
lock.acquire()
389388

390389

391-
@pytest.mark.subprocess(env=dict(DD_PROFILING_ENABLE_ASSERTS="false", DD_PROFILING_ENABLED="1"), ddtrace_run=True)
390+
@pytest.mark.subprocess(env=dict(DD_PROFILING_ENABLE_ASSERTS="false"))
392391
def test_all_exceptions_suppressed_by_default() -> None:
393392
"""
394393
Ensure that exceptions are silently suppressed in the `_acquire` method

0 commit comments

Comments
 (0)