Skip to main content

A flexible and convenient solution for managing process priorities - Windows only

pip install change-proc-priority

Tested against Windows 10 / Python 3.10 / Anaconda

This module offers a flexible and convenient solution for managing process priorities, making it valuable for system administrators, performance optimizers, developers, and researchers who need to fine-tune resource allocation and optimize system performance

Process Priority Control:

The module provides functionality to monitor and change the priority of processes running on a system. This can be useful in scenarios where fine-tuning the priority of specific processes can have a significant impact on system performance or resource allocation.

Constant Monitoring:

The constant_check_and_change_priority function allows for continuous monitoring of processes, ensuring that the desired priority is maintained even if processes are created or terminated dynamically.

Regular Expression Support:

The module supports using regular expressions to specify the executable path of the target processes. This provides flexibility in defining patterns and allows for more complex matching criteria.

CLI and Function Interface:

The module can be utilized both through the command line interface (CLI) and by directly calling the constant_check_and_change_priority function in Python code. This provides versatility in how the module can be incorporated into different workflows and automation processes.

Customizable Parameters:

The module allows for customization of various parameters such as priority, delay between checks, and the ability to close the program after the first matching process is found. This flexibility enables users to tailor the behavior of the module according to their specific requirements.

constant_check_and_change_priority(
    exe_path: str | None = None,
    priority: int = NORMAL,
    is_regex: int | bool = 1,
    flags: int = re.I,
    delay: float | int = 1.0,
    close_after_first: int | bool = 0,
):
    r"""
    Constantly checks and changes the priority of processes based on the provided parameters.

    Args:
        exe_path (str | None): Path or regular expression pattern of the executable to monitor.
        priority (int): Priority value to set for the processes. Valid options are:
            - LOW = 64
            - BELOW_NORMAL = 16384
            - NORMAL = 32
            - ABOVE_NORMAL = 32768
            - HIGH = 128
            - REALTIME = 256
            Defaults to NORMAL (32).
        is_regex (int | bool): Flag indicating whether the exe_path should be treated as a regular expression pattern.
            Defaults to 1 (True).
        flags (int): Flags to be used with the regular expression pattern. Defaults to re.I (ignore case).
        delay (float | int): Delay in seconds between each check. Defaults to 1.0.
        close_after_first (int | bool): Flag indicating whether to exit the program after the first process is found.
            Defaults to 0 (False).

    Returns:
        Callable: A function that can be used to stop the monitoring thread.

    Example:
        Changing priority of one process - function call:
        This line shows an example of calling the change_priority function to change the priority of a specific process
        with a given PID. In this case, the priority is set to HIGH. The PID used here is 21360.

        change_priority(pid=21360,priority=HIGH)
        #################################################
        Constantly changing priority of processes with exe_path - CLI:
        This line demonstrates how to use the script from the command line interface (CLI)
        to constantly monitor and change the priority of processes based on the specified exe_path parameter.
        The script is invoked using the python command, followed by the script path.
        The CLI arguments are provided using -- followed by the argument name and its corresponding value.
        In this example, the exe_path is set to notepad.exe$, the priority is set to 128 (which corresponds
        to HIGH priority), is_regex is set to 1 (True), flags is set to 2, delay is set to 2.0 seconds,
        and close_after_first is set to 0 (False).

        # adjust the path!
        python .\__init__.py --exe_path notepad.exe$ --priority 128 --is_regex 1 --flags 2 --delay 2.0 --close_after_first 0
        #################################################


        This part showcases an example of using the constant_check_and_change_priority function directly in Python code.
        The function is called with various parameters to monitor and change the priority of processes.
        In this example, the exe_path is set to "notepad.exe$", indicating a regular expression pattern,
        the priority is set to NORMAL, is_regex is set to True, flags is set to re.I (ignore case),
        delay is set to 1.0 second, and close_after_first is set to False.
		
		from change_proc_priority import constant_check_and_change_priority
        stop_monitoring=constant_check_and_change_priority(
        exe_path="notepad.exe$",
        priority=NORMAL,
        is_regex=True,
        flags=re.I,
        delay=1.0,
        close_after_first=False,
        )
        #################################################

        # To stop the monitoring thread, call the returned function
        stop_monitoring()
    """

Metadata

Release files for change-proc-priority 0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for change-proc-priority 0.10
File Size Uploaded Provenance Actions
change_proc_priority-0.10.tar.gz 7.7 kB Without provenance Details for change_proc_priority-0.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for change-proc-priority 0.10
File Interpreter ABI Platform Actions
change_proc_priority-0.10-py3-none-any.whl Python 3 none any Details for change_proc_priority-0.10-py3-none-any.whl

Total release size: 18.4 kB

Release files / change_proc_priority-0.10.tar.gz

Download URL change_proc_priority-0.10.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
01d5b8ce3c1861b4a687d552a7dfcf4b4b924d033ff5928f3f579a5410924f50
BLAKE2b-256 checksum
How to use checksums
1f839734ec43ceb2549c9945bed37bdf108186f7d8b9c1aecd5b71bc8fa24927
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / change_proc_priority-0.10-py3-none-any.whl

Download URL change_proc_priority-0.10-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3b50d945d0a94d43c0fe634d0ba332da6129948a3921e1b8ac7a198e7b8eb2c
BLAKE2b-256 checksum
How to use checksums
5f1b34862850e509006979c11c4d74f9271ba551e4463bf90df5533b2c12959d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Security for change-proc-priority 0.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page