Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-40280: Omit wait, getrusage, and prlimit on Emscripten
  • Loading branch information
tiran committed Feb 5, 2022
commit 165a464390f4e02c25a55b814d6102c16a51e76d
2 changes: 2 additions & 0 deletions Lib/test/support/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,8 @@ def reap_children():
# Need os.waitpid(-1, os.WNOHANG): Windows is not supported
if not (hasattr(os, 'waitpid') and hasattr(os, 'WNOHANG')):
return
if not has_subprocess_support:
Comment thread
tiran marked this conversation as resolved.
Outdated
return

# Reap all our dead child processes so we don't leave zombies around.
# These hog resources and might be causing some of the buildbots to die.
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/support/os_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def __fspath__(self):
def fd_count():
"""Count the number of open file descriptors.
"""
if sys.platform.startswith(('linux', 'freebsd')):
if sys.platform.startswith(('linux', 'freebsd', 'emscripten')):
try:
names = os.listdir("/proc/self/fd")
# Subtract one because listdir() internally opens a file
Expand Down
2 changes: 2 additions & 0 deletions Lib/test/test_capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ def check_fatal_error(self, code, expected, not_expected=()):
self.assertNotIn(name, modules)
self.assertEqual(len(modules), total)

@support.requires_subprocess()
def test_fatal_error(self):
# By default, stdlib extension modules are ignored,
# but not test modules.
Expand Down Expand Up @@ -880,6 +881,7 @@ class Test_testinternalcapi(unittest.TestCase):
if name.startswith('test_'))


@support.requires_subprocess()
class PyMemDebugTests(unittest.TestCase):
PYTHONMALLOC = 'debug'
# '0x04c06e0' or '04C06E0'
Expand Down
3 changes: 3 additions & 0 deletions Lib/test/test_faulthandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
except ImportError:
_testcapi = None

if not support.has_subprocess_support:
raise unittest.SkipTest("test module requires subprocess")

TIMEOUT = 0.5
MS_WINDOWS = (os.name == 'nt')

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def test_fsize_toobig(self):
except (OverflowError, ValueError):
pass

@unittest.skipUnless(hasattr(resource, "getrusage"), "needs getrusage")
def test_getrusage(self):
self.assertRaises(TypeError, resource.getrusage)
self.assertRaises(TypeError, resource.getrusage, 42, 42)
Expand Down
10 changes: 9 additions & 1 deletion Modules/clinic/resource.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Modules/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ get_resource_state(PyObject *module)

static struct PyModuleDef resourcemodule;

#ifdef HAVE_GETRUSAGE
/*[clinic input]
resource.getrusage

Expand Down Expand Up @@ -134,6 +135,7 @@ resource_getrusage_impl(PyObject *module, int who)

return result;
}
#endif

static int
py2rlimit(PyObject *limits, struct rlimit *rl_out)
Expand Down
2 changes: 1 addition & 1 deletion Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1282,7 +1282,7 @@ _PyTime_GetProcessTimeWithInfo(_PyTime_t *tp, _Py_clock_info_t *info)
#endif

/* getrusage(RUSAGE_SELF) */
#if defined(HAVE_SYS_RESOURCE_H)
#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRUSAGE)
struct rusage ru;

if (getrusage(RUSAGE_SELF, &ru) == 0) {
Expand Down
4 changes: 4 additions & 0 deletions Tools/wasm/config.site-wasm32-emscripten
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ ac_cv_func_pwritev=no
ac_cv_func_pipe2=no
ac_cv_func_nice=no
ac_cv_func_setitimer=no
# unsupported syscall: __syscall_prlimit64
ac_cv_func_prlimit=no
# unsupported syscall: __syscall_getrusage
ac_cv_func_getrusage=no

# Syscalls that resulted in a segfault
ac_cv_func_utimensat=no
Expand Down
2 changes: 1 addition & 1 deletion configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4144,7 +4144,7 @@ AC_CHECK_FUNCS([ \
gai_strerror getegid getentropy geteuid getgid getgrgid getgrgid_r \
getgrnam_r getgrouplist getgroups getitimer getloadavg getlogin \
getpeername getpgid getpid getppid getpriority _getpty \
getpwent getpwnam_r getpwuid_r getresgid getresuid getsid getspent \
getpwent getpwnam_r getpwuid_r getresgid getresuid getrusage getsid getspent \
getspnam getuid getwd if_nameindex initgroups kill killpg lchown linkat \
lockf lstat lutimes madvise mbrtowc memrchr mkdirat mkfifo mkfifoat \
mknod mknodat mktime mmap mremap nice openat opendir pathconf pause pipe \
Expand Down
3 changes: 3 additions & 0 deletions pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@
/* Define to 1 if you have the `getresuid' function. */
#undef HAVE_GETRESUID

/* Define to 1 if you have the `getrusage' function. */
#undef HAVE_GETRUSAGE

/* Define to 1 if you have the `getsid' function. */
#undef HAVE_GETSID

Expand Down