Skip to content

scheduler tests for posix_spawn fail on glibc for SCHED_BATCH #138163

@encukou

Description

@encukou

On glibc, posix_spawnattr_setschedpolicy cannot change the policy to SCHED_BATCH, even if that is the current policy.

$ chrt -b 0 ./python -m test test_posix -m '*scheduler*' -v
[...]

======================================================================
ERROR: test_setscheduler_with_policy (test.test_posix.TestPosixSpawn.test_setscheduler_with_policy)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/encukou/dev/cpython/Lib/test/test_posix.py", line 2048, in test_setscheduler_with_policy
    pid = self.spawn_func(
        sys.executable,
    ...<2 lines>...
        scheduler=(policy, os.sched_param(priority))
    )
OSError: [Errno 22] Invalid argument

[same in test.test_posix.TestPosixSpawnP]
FAILED (errors=2)

POSIX says:

If the current scheduling policy for the target process is not SCHED_FIFO, SCHED_RR, [or SCHED_SPORADIC,] the result is implementation-defined; this case includes the SCHED_OTHER policy.

AFAICS, the test should be skipped for platform.libc_ver()[0] == 'glibc' if os.sched_getscheduler returned os.SCHED_BATCH, os.SCHED_IDLE, or os.SCHED_DEADLINE.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions