Skip to content

fix: use platform.node() for AGENT_PING to avoid gevent import deadlock - #3232

Open
craigpnnl wants to merge 2 commits into
VOLTTRON:developfrom
craigpnnl:test/platform-auth-fixes
Open

fix: use platform.node() for AGENT_PING to avoid gevent import deadlock#3232
craigpnnl wants to merge 2 commits into
VOLTTRON:developfrom
craigpnnl:test/platform-auth-fixes

Conversation

@craigpnnl

Copy link
Copy Markdown
Contributor

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.auth hangs 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:

pytest volttrontesting/platform/auth_tests -m auth

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.

craigpnnl added 2 commits July 9, 2026 16:41
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant