-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pytest deadlock when using gevent [backport 2.8] (#9166)
Backport 9e862f9 from #9141 to 2.8. Fixes #8281 This fix resolves an issue when using ``pytest`` + ``gevent`` where the telemetry writer was eager initialized by ``pytest`` entrypoints loading of our plugin causing a potential dead lock. The specific case that we targeted solving with this PR: ```python import ddtrace import gevent.monkey gevent.monkey.patch_all() def test_thing(): pass ``` ```shell $ pytest test.py $ pytest -p ddtrace -p ddtrace.pytest_bdd -p ddtrace.pytest_benchmark test.py $ pytest -p no:ddtrace -p no:ddtrace.pytest_bdd -p no:ddtrace.pytest_benchmark test.py ``` Previously would dead-lock, but now will execute without problem. We no longer get telemetry enabled and sending data just from `import ddtrace`. Moving telemetry writer starting to `ddtrace.bootstrap.preload` will mean that any unhandled exceptions that occur before the telemetry writer can be started will not get reported. - [x] Change(s) are motivated and described in the PR description - [x] Testing strategy is described if automated tests are not included in the PR - [x] Risks are described (performance impact, potential for breakage, maintainability) - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] [Library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) are followed or label `changelog/no-changelog` is set - [x] Documentation is included (in-code, generated user docs, [public corp docs](https://github.com/DataDog/documentation/)) - [x] Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) - [x] If this PR changes the public interface, I've notified `@DataDog/apm-tees`. - [x] Title is accurate - [x] All changes are related to the pull request's stated goal - [x] Description motivates each change - [x] Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - [x] Testing strategy adequately addresses listed risks - [x] Change is maintainable (easy to change, telemetry, documentation) - [x] Release note makes sense to a user of the library - [x] Author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - [x] Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
- Loading branch information
1 parent
d8a5718
commit a5ee561
Showing
18 changed files
with
235 additions
and
138 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.10 | ||
# by the following command: | ||
# | ||
# pip-compile --no-annotate --resolver=backtracking .riot/requirements/1b90fc9.in | ||
# | ||
attrs==23.2.0 | ||
coverage[toml]==7.5.0 | ||
exceptiongroup==1.2.1 | ||
gevent==24.2.1 | ||
greenlet==3.0.3 | ||
hypothesis==6.45.0 | ||
iniconfig==2.0.0 | ||
mock==5.1.0 | ||
msgpack==1.0.8 | ||
opentracing==2.4.0 | ||
packaging==24.0 | ||
pluggy==1.5.0 | ||
pytest==8.2.0 | ||
pytest-cov==5.0.0 | ||
pytest-mock==3.14.0 | ||
pytest-randomly==3.15.0 | ||
sortedcontainers==2.4.0 | ||
tomli==2.0.1 | ||
zope-event==5.0 | ||
zope-interface==6.3 | ||
|
||
# The following packages are considered to be unsafe in a requirements file: | ||
# setuptools |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.8 | ||
# by the following command: | ||
# | ||
# pip-compile --no-annotate .riot/requirements/27d0ff3.in | ||
# | ||
attrs==23.2.0 | ||
coverage[toml]==7.5.0 | ||
exceptiongroup==1.2.1 | ||
gevent==24.2.1 | ||
greenlet==3.0.3 | ||
hypothesis==6.45.0 | ||
importlib-metadata==7.1.0 | ||
iniconfig==2.0.0 | ||
mock==5.1.0 | ||
msgpack==1.0.8 | ||
opentracing==2.4.0 | ||
packaging==24.0 | ||
pluggy==1.5.0 | ||
pytest==8.2.0 | ||
pytest-cov==5.0.0 | ||
pytest-mock==3.14.0 | ||
pytest-randomly==3.15.0 | ||
sortedcontainers==2.4.0 | ||
tomli==2.0.1 | ||
zipp==3.18.1 | ||
zope-event==5.0 | ||
zope-interface==6.3 | ||
|
||
# The following packages are considered to be unsafe in a requirements file: | ||
# setuptools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.9 | ||
# by the following command: | ||
# | ||
# pip-compile --no-annotate .riot/requirements/61891b4.in | ||
# | ||
attrs==23.2.0 | ||
coverage[toml]==7.5.0 | ||
exceptiongroup==1.2.1 | ||
gevent==24.2.1 | ||
greenlet==3.0.3 | ||
hypothesis==6.45.0 | ||
importlib-metadata==7.1.0 | ||
iniconfig==2.0.0 | ||
mock==5.1.0 | ||
msgpack==1.0.8 | ||
opentracing==2.4.0 | ||
packaging==24.0 | ||
pluggy==1.5.0 | ||
pytest==8.2.0 | ||
pytest-cov==5.0.0 | ||
pytest-mock==3.14.0 | ||
pytest-randomly==3.15.0 | ||
sortedcontainers==2.4.0 | ||
tomli==2.0.1 | ||
zipp==3.18.1 | ||
zope-event==5.0 | ||
zope-interface==6.3 | ||
|
||
# The following packages are considered to be unsafe in a requirements file: | ||
# setuptools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.11 | ||
# by the following command: | ||
# | ||
# pip-compile --no-annotate .riot/requirements/d171c08.in | ||
# | ||
attrs==23.2.0 | ||
coverage[toml]==7.5.0 | ||
gevent==24.2.1 | ||
greenlet==3.0.3 | ||
hypothesis==6.45.0 | ||
iniconfig==2.0.0 | ||
mock==5.1.0 | ||
msgpack==1.0.8 | ||
opentracing==2.4.0 | ||
packaging==24.0 | ||
pluggy==1.5.0 | ||
pytest==8.2.0 | ||
pytest-cov==5.0.0 | ||
pytest-mock==3.14.0 | ||
pytest-randomly==3.15.0 | ||
sortedcontainers==2.4.0 | ||
zope-event==5.0 | ||
zope-interface==6.3 | ||
|
||
# The following packages are considered to be unsafe in a requirements file: | ||
# setuptools |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# | ||
# This file is autogenerated by pip-compile with Python 3.12 | ||
# by the following command: | ||
# | ||
# pip-compile --no-annotate .riot/requirements/de578a7.in | ||
# | ||
attrs==23.2.0 | ||
coverage[toml]==7.5.0 | ||
gevent==24.2.1 | ||
greenlet==3.0.3 | ||
hypothesis==6.45.0 | ||
iniconfig==2.0.0 | ||
mock==5.1.0 | ||
msgpack==1.0.8 | ||
opentracing==2.4.0 | ||
packaging==24.0 | ||
pluggy==1.5.0 | ||
pytest==8.2.0 | ||
pytest-cov==5.0.0 | ||
pytest-mock==3.14.0 | ||
pytest-randomly==3.15.0 | ||
sortedcontainers==2.4.0 | ||
zope-event==5.0 | ||
zope-interface==6.3 | ||
|
||
# The following packages are considered to be unsafe in a requirements file: | ||
# setuptools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
releasenotes/notes/fix-telemetry-writer-initialization-163b1effc09d948f.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
fixes: | ||
- | | ||
telemetry: This fix resolves an issue when using ``pytest`` + ``gevent`` where the telemetry writer was eager initialized by ``pytest`` entrypoints loading of our plugin causing a potential dead lock. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.