-
Notifications
You must be signed in to change notification settings - Fork 526
fix(native): run shutdown in thread in uwsgi #19086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: repro/uwsgi-tokio-panic
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -851,7 +851,9 @@ def set_test_session_token(self, token: Optional[str]) -> None: | |
| :param token: The test session token to use for authentication. | ||
| """ | ||
| self._test_session_token = token | ||
| old_exporter = self._exporter | ||
| self._exporter = self._create_exporter() | ||
| old_exporter.shutdown(3_000_000_000) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This new explicit shutdown covers token/API swaps, but Useful? React with 👍 / 👎. |
||
|
|
||
| def recreate( | ||
| self, | ||
|
|
@@ -890,7 +892,9 @@ def _downgrade(self, status, client): | |
| if client.ENDPOINT == "v0.5/traces": | ||
| self._clients = [AgentWriterClientV4(self._buffer_size, self._max_payload_size)] | ||
| self._api_version = "v0.4" | ||
| old_exporter = self._exporter | ||
| self._exporter = self._create_exporter() | ||
| old_exporter.shutdown(3_000_000_000) | ||
|
|
||
| # Since we have to change the encoding in this case, the payload | ||
| # would need to be converted to the downgraded encoding before | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| fixes: | ||
| - | | ||
| Fix crashes in uwsgi worker when exiting from SIGTERM. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running under uWSGI on Python versions where the server injects the synthetic
uwsgimodule without a module spec,importlib.util.find_spec("uwsgi")raisesValueErrorinstead of returning a truthy value. Since_atexit()catches that exception, SIGTERM exits skipshutdown_in_thread()entirely, so the uWSGI crash path this change is meant to fix still uses no native-runtime shutdown; useimport uwsgi/sys.modulesor the existing uWSGI helper and handleValueErrorhere.Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 I agree with this feedback, I thik uwsgi directly injects the module in
sys.modules, so doing a pyimport ofuwsgior checkingsys.modules["uwsgi"]would be better