fix(utils): don't warn when network is unreachable in _get_ip - #9360
fix(utils): don't warn when network is unreachable in _get_ip#9360fwh888 wants to merge 1 commit into
Conversation
LocalCluster(processes=False) on a machine without external connectivity
emits a spurious RuntimeWarning ("Couldn't detect a suitable IP address
for reaching '8.8.8.8'...") every time it starts.
ENETUNREACH / EHOSTUNREACH / ENETDOWN are expected on offline machines;
the hostname fallback already yields a usable local address, so only
warn for genuine socket errors (e.g. EACCES), not for ordinary offline
use.
Adds unit tests covering:
- silent downgrade on ENETUNREACH (no RuntimeWarning)
- preserved warning for other OSError (EACCES)
- normal UDP probe returns the local address without warning
9fd966d to
92c89ad
Compare
|
Hi maintainers 👋 — a quick note on the current CI status to make review easier: Green (relevant to this PR):
The 3 failures are unrelated to this change:
The change itself is narrow: Happy to rerun or adjust anything. Thanks! |
Unit Test ResultsSee test report for an extended history of previous test failures. This is useful for diagnosing flaky tests. 40 files ± 0 40 suites ±0 14h 43m 21s ⏱️ + 24m 23s For more details on these failures, see this check. Results for commit 92c89ad. ± Comparison against base commit dc182bd. |
Summary
LocalCluster(processes=False)on a machine without external connectivity emits a spuriousRuntimeWarningevery time it starts:The UDP probe in
_get_ipraisesOSErrorwhen the default probe host8.8.8.8is unreachable (offline machine). This is an expected, recoverable condition — thehostname_fallback()path already yields a usable local address.Changes
In
distributed/utils.py,_get_ipnow silently downgrades to the hostname fallback for network-unreachable errors (ENETUNREACH,EHOSTUNREACH,ENETDOWN) instead of emitting aRuntimeWarning. Genuine socket errors (e.g.EACCES) still warn as before.Tests
Added unit tests in
tests/test_utils.py:test_get_ip_silent_when_network_unreachable— asserts no warning is raised onENETUNREACHtest_get_ip_warns_for_other_socket_errors— assertsEACCESstill warnstest_get_ip_returns_local_address— normal probe path unchangedAll updated tests pass;
ruffandpre-commitclean on touched files.Fixes #8559