From 07adcb3131076dd86e1f8237de8c97487bf26101 Mon Sep 17 00:00:00 2001 From: Alexey Izbyshev Date: Thu, 23 Feb 2023 20:38:25 +0300 Subject: [PATCH] gh-102184: Test os.sync() only if "largefile" resource is enabled Calling `os.sync()` when the Linux page cache is large and full of dirty pages and the storage device is slow can block the process in "uninterruptible sleep" state for minutes, making the test run unkillable even with SIGKILL. Avoid this by testing `os.sync()` only if "largefile" resource is enabled. --- Lib/test/test_posix.py | 6 +++++- .../Tests/2023-02-23-17-38-36.gh-issue-102184.W71J5G.rst | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Tests/2023-02-23-17-38-36.gh-issue-102184.W71J5G.rst diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py index 77f42f7f9c937b..fb1989150c15d8 100644 --- a/Lib/test/test_posix.py +++ b/Lib/test/test_posix.py @@ -66,8 +66,12 @@ def testNoArgFunctions(self): NO_ARG_FUNCTIONS = [ "ctermid", "getcwd", "getcwdb", "uname", "times", "getloadavg", "getegid", "geteuid", "getgid", "getgroups", - "getpid", "getpgrp", "getppid", "getuid", "sync", + "getpid", "getpgrp", "getppid", "getuid", ] + # gh-102184: Don't test sync() by default since it might cause heavy + # I/O and block for a long time. + if support.is_resource_enabled('largefile'): + NO_ARG_FUNCTIONS.append("sync") for name in NO_ARG_FUNCTIONS: posix_func = getattr(posix, name, None) diff --git a/Misc/NEWS.d/next/Tests/2023-02-23-17-38-36.gh-issue-102184.W71J5G.rst b/Misc/NEWS.d/next/Tests/2023-02-23-17-38-36.gh-issue-102184.W71J5G.rst new file mode 100644 index 00000000000000..5bbfc5b2dd5966 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2023-02-23-17-38-36.gh-issue-102184.W71J5G.rst @@ -0,0 +1 @@ +Test ``os.sync()`` only if "largefile" resource is enabled.