Skip to content

Commit 57e7e07

Browse files
authored
chore(gevent): disable gevent hub reinit (backport #4252) (#4267)
This is an automatic backport of pull request #4252 done by [Mergify](https://mergify.com). --- <details> <summary>Mergify commands and options</summary> <br /> More conditions and actions can be found in the [documentation](https://docs.mergify.com/). You can also trigger Mergify actions by commenting on this pull request: - `@Mergifyio refresh` will re-evaluate the rules - `@Mergifyio rebase` will rebase this PR on its base branch - `@Mergifyio update` will merge the base branch into this PR - `@Mergifyio backport <destination>` will backport this PR on `<destination>` branch Additionally, on Mergify [dashboard](https://dashboard.mergify.com/) you can: - look at your merge queues - generate the Mergify configuration with the config editor. Finally, you can contact us on https://mergify.com </details>
1 parent 794efc8 commit 57e7e07

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

ddtrace/internal/forksafe.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import weakref
99

1010
from ddtrace.internal.module import ModuleWatchdog
11+
from ddtrace.internal.utils.formats import asbool
1112
from ddtrace.vendor import wrapt
1213

1314

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

4142

42-
ModuleWatchdog.register_module_hook("gevent.hub", patch_gevent_hub_reinit)
43+
if asbool(os.getenv("_DD_TRACE_GEVENT_HUB_PATCHED", default=False)):
44+
ModuleWatchdog.register_module_hook("gevent.hub", patch_gevent_hub_reinit)
4345

4446

4547
def ddtrace_after_in_child():

tests/internal/test_forksafe.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ def fn():
291291
@pytest.mark.subprocess(
292292
out="" if (3,) < sys.version_info < (3, 7) else ("CTCTCT" if sys.platform == "darwin" else "CCCTTT"),
293293
err=None,
294+
env=dict(_DD_TRACE_GEVENT_HUB_PATCHED="true"),
294295
)
295296
def test_gevent_reinit_patch():
296297
import os

0 commit comments

Comments
 (0)