From 9fd8af20ff871d7a7d7a31b867cbb19f90730386 Mon Sep 17 00:00:00 2001 From: Stepan Shamaiev <59963936+skippdot@users.noreply.github.com> Date: Thu, 15 Oct 2026 17:03:11 +0300 Subject: [PATCH] fix(gh-158883): Skip VSOCK stream test on ENODEV - Probe connect() in setUp() before the client thread is released - connect() failing with ENODEV left accept() waiting until the timeout - Skip the test on ENODEV, like setUp() already does for bind() EADDRNOTAVAIL Claude-Session: https://claude.ai/code/session_012KaMNAQbRhdZQBYZenroY2 --- Lib/test/test_socket.py | 17 ++++++++++++++++- ...26-10-13-18-48-29.gh-issue-158883.vS0cKd.rst | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Tests/2026-10-13-18-48-29.gh-issue-158883.vS0cKd.rst diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index e4b3d848923f8c9..0814f75ab1aab35 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -608,8 +608,23 @@ def setUp(self): else: raise self.serv.listen() - self.serverExplicitReady() self.serv.settimeout(support.LOOPBACK_TIMEOUT) + # gh-158883: The local CID can be known even if no transport is able + # to deliver a connection to it. Check that before the client thread + # is released: once it is, a failing connect() leaves accept() below + # waiting for the timeout. + with socket.socket(socket.AF_VSOCK, socket.SOCK_STREAM) as probe: + probe.settimeout(support.LOOPBACK_TIMEOUT) + try: + probe.connect((cid, VSOCKPORT)) + except OSError as exc: + if exc.errno == errno.ENODEV: + self.skipTest(f"connect() failed with {exc!r}") + else: + raise + conn, _ = self.serv.accept() + conn.close() + self.serverExplicitReady() self.conn, self.connaddr = self.serv.accept() self.addCleanup(self.conn.close) diff --git a/Misc/NEWS.d/next/Tests/2026-10-13-18-48-29.gh-issue-158883.vS0cKd.rst b/Misc/NEWS.d/next/Tests/2026-10-13-18-48-29.gh-issue-158883.vS0cKd.rst new file mode 100644 index 000000000000000..82ec67b55e64db2 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2026-10-13-18-48-29.gh-issue-158883.vS0cKd.rst @@ -0,0 +1,3 @@ +Skip ``test_socket.ThreadedVSOCKSocketStreamTest`` when connecting to the +local ``AF_VSOCK`` address fails with :data:`~errno.ENODEV`, instead of +failing with a timeout.