Skip to content

Commit

Permalink
chore(gevent): disable gevent hub reinit (#4252)
Browse files Browse the repository at this point in the history
Re-initialize the gevent hub after-in-child fork hooks when DD_TRACE_GEVENT_HUB_PATCHED is set to true. This mitigates a performance regression introduced by: #4070.
  • Loading branch information
mabdinur authored Oct 3, 2022
1 parent 0ba3e29 commit 57ea1f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ddtrace/internal/forksafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import weakref

from ddtrace.internal.module import ModuleWatchdog
from ddtrace.internal.utils.formats import asbool
from ddtrace.vendor import wrapt


Expand Down Expand Up @@ -39,7 +40,8 @@ def wrapped_reinit(f, args, kwargs):
wrap(module.reinit, wrapped_reinit)


ModuleWatchdog.register_module_hook("gevent.hub", patch_gevent_hub_reinit)
if asbool(os.getenv("_DD_TRACE_GEVENT_HUB_PATCHED", default=False)):
ModuleWatchdog.register_module_hook("gevent.hub", patch_gevent_hub_reinit)


def ddtrace_after_in_child():
Expand Down
1 change: 1 addition & 0 deletions tests/internal/test_forksafe.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ def fn():
@pytest.mark.subprocess(
out="" if (3,) < sys.version_info < (3, 7) else ("CTCTCT" if sys.platform == "darwin" else "CCCTTT"),
err=None,
env=dict(_DD_TRACE_GEVENT_HUB_PATCHED="true"),
)
def test_gevent_reinit_patch():
import os
Expand Down

0 comments on commit 57ea1f8

Please sign in to comment.