Skip to content

Allow richer expressions in -n auto #477

@LivInTheLookingGlass

Description

@LivInTheLookingGlass

It would be nice if we could put things like pytest -n auto-1 and have it correctly interpret that as "all CPUs except 1". This ensures that the processor is not hogged by tests, but also that it runs at a very fast clip.

Could be done something like:

cores = 1
if 'auto' in args.n:
    cores = cpu_count()
    if '-' in args.n:
        cores -= int(args.n.split('-')[1])
    elif args.n != 'auto':
        raise ValueError("Invalid option given!")
else:
    cores = int(args.n)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions