fix: use platform.node() for AGENT_PING to avoid gevent import deadlock - #3232
Open
craigpnnl wants to merge 2 commits into
Open
fix: use platform.node() for AGENT_PING to avoid gevent import deadlock#3232craigpnnl wants to merge 2 commits into
craigpnnl wants to merge 2 commits into
Conversation
…rt deadlock topics.py computed AGENT_PING at module import via platform.uname()[1]. platform.uname() shells out to a subprocess to fill its processor field, and that subprocess call deadlocks at import time under gevent's monkey-patched os on newer CPython (observed hanging the entire volttron.platform.auth import chain on Python 3.13). platform.node() returns the identical node name by reading the hostname directly with no subprocess, so this is a behavior-preserving fix that lets the auth package import on modern interpreters while leaving the pinned 3.10 toolchain unaffected.
Adds a regression test asserting the auth package imports cleanly and that AGENT_PING renders agent/ping/<node>/<pid>/<cookie> with the real hostname and pid, not just that rendering does not crash. Verified RED on Python 3.13 with the prior platform.uname()[1] code (import deadlocked at 18s) and GREEN with the platform.node() fix.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3231
Problem
volttron/platform/messaging/topics.py builds the AGENT_PING topic at module import time from platform.uname()[1]. platform.uname() shells out to a subprocess to populate its "processor" field, and under gevent's monkey-patched os that subprocess call deadlocks at import time on modern CPython (observed hanging on Python 3.13). Because the auth import chain reaches topics.py,
import volttron.platform.authhangs and the platform auth tests cannot run. faulthandler pins the hang at topics.py:91.Fix
Replace platform.uname()[1] with platform.node(). Both return the identical node name, but node() reads the hostname directly with no subprocess. This is a behavior-preserving change that lets the auth package import on modern interpreters while leaving the pinned 3.10 toolchain unaffected.
A regression test (volttrontesting/platform/auth_tests/test_auth_import.py) asserts two things: the auth package imports cleanly, and AGENT_PING renders agent/ping/// with the real hostname and pid values, not merely that rendering does not crash.
Test plan
Ran the auth test suite the CI way on Python 3.10:
Result: 48 passed, 70 skipped, 2 xfailed.
The regression test was verified RED on Python 3.13 with the prior platform.uname()[1] code (import deadlocked at roughly 18s) and GREEN with the platform.node() fix.