change-proc-priority


Namechange-proc-priority JSON
Version 0.10 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/change_proc_priority
SummaryConstantly checks and changes the priority of processes based on the provided parameters - Windows only
upload_time2023-05-31 07:37:48
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords priority processes
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# 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.


```python
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()
    """
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/change_proc_priority",
    "name": "change-proc-priority",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "priority,processes",
    "author": "Johannes Fischer",
    "author_email": "aulasparticularesdealemaosp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/1f/83/9734ec43ceb2549c9945bed37bdf108186f7d8b9c1aecd5b71bc8fa24927/change_proc_priority-0.10.tar.gz",
    "platform": null,
    "description": "\r\n# A flexible and convenient solution for managing process priorities - Windows only\r\n\r\n## pip install change-proc-priority\r\n\r\n#### Tested against Windows 10 / Python 3.10 / Anaconda\r\n\r\n\r\nThis 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\r\n\r\n\r\n\r\n### Process Priority Control: \r\n\r\nThe module provides functionality to monitor and change the priority of processes running on a system. \r\nThis can be useful in scenarios where fine-tuning the priority of specific processes can have a \r\nsignificant impact on system performance or resource allocation.\r\n\r\n### Constant Monitoring: \r\n\r\nThe constant_check_and_change_priority function allows for continuous monitoring of processes, \r\nensuring that the desired priority is maintained even if processes are created or terminated dynamically.\r\n\r\n### Regular Expression Support: \r\n\r\nThe module supports using regular expressions to specify the executable path of the target processes. \r\nThis provides flexibility in defining patterns and allows for more complex matching criteria.\r\n\r\n### CLI and Function Interface: \r\n\r\nThe 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. \r\nThis provides versatility in how the module can be incorporated into different workflows and automation processes.\r\n\r\n### Customizable Parameters: \r\n\r\nThe 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. \r\nThis flexibility enables users to tailor the behavior of the module according to their specific requirements.\r\n\r\n\r\n```python\r\nconstant_check_and_change_priority(\r\n    exe_path: str | None = None,\r\n    priority: int = NORMAL,\r\n    is_regex: int | bool = 1,\r\n    flags: int = re.I,\r\n    delay: float | int = 1.0,\r\n    close_after_first: int | bool = 0,\r\n):\r\n    r\"\"\"\r\n    Constantly checks and changes the priority of processes based on the provided parameters.\r\n\r\n    Args:\r\n        exe_path (str | None): Path or regular expression pattern of the executable to monitor.\r\n        priority (int): Priority value to set for the processes. Valid options are:\r\n            - LOW = 64\r\n            - BELOW_NORMAL = 16384\r\n            - NORMAL = 32\r\n            - ABOVE_NORMAL = 32768\r\n            - HIGH = 128\r\n            - REALTIME = 256\r\n            Defaults to NORMAL (32).\r\n        is_regex (int | bool): Flag indicating whether the exe_path should be treated as a regular expression pattern.\r\n            Defaults to 1 (True).\r\n        flags (int): Flags to be used with the regular expression pattern. Defaults to re.I (ignore case).\r\n        delay (float | int): Delay in seconds between each check. Defaults to 1.0.\r\n        close_after_first (int | bool): Flag indicating whether to exit the program after the first process is found.\r\n            Defaults to 0 (False).\r\n\r\n    Returns:\r\n        Callable: A function that can be used to stop the monitoring thread.\r\n\r\n    Example:\r\n        Changing priority of one process - function call:\r\n        This line shows an example of calling the change_priority function to change the priority of a specific process\r\n        with a given PID. In this case, the priority is set to HIGH. The PID used here is 21360.\r\n\r\n        change_priority(pid=21360,priority=HIGH)\r\n        #################################################\r\n        Constantly changing priority of processes with exe_path - CLI:\r\n        This line demonstrates how to use the script from the command line interface (CLI)\r\n        to constantly monitor and change the priority of processes based on the specified exe_path parameter.\r\n        The script is invoked using the python command, followed by the script path.\r\n        The CLI arguments are provided using -- followed by the argument name and its corresponding value.\r\n        In this example, the exe_path is set to notepad.exe$, the priority is set to 128 (which corresponds\r\n        to HIGH priority), is_regex is set to 1 (True), flags is set to 2, delay is set to 2.0 seconds,\r\n        and close_after_first is set to 0 (False).\r\n\r\n        # adjust the path!\r\n        python .\\__init__.py --exe_path notepad.exe$ --priority 128 --is_regex 1 --flags 2 --delay 2.0 --close_after_first 0\r\n        #################################################\r\n\r\n\r\n        This part showcases an example of using the constant_check_and_change_priority function directly in Python code.\r\n        The function is called with various parameters to monitor and change the priority of processes.\r\n        In this example, the exe_path is set to \"notepad.exe$\", indicating a regular expression pattern,\r\n        the priority is set to NORMAL, is_regex is set to True, flags is set to re.I (ignore case),\r\n        delay is set to 1.0 second, and close_after_first is set to False.\r\n\t\t\r\n\t\tfrom change_proc_priority import constant_check_and_change_priority\r\n        stop_monitoring=constant_check_and_change_priority(\r\n        exe_path=\"notepad.exe$\",\r\n        priority=NORMAL,\r\n        is_regex=True,\r\n        flags=re.I,\r\n        delay=1.0,\r\n        close_after_first=False,\r\n        )\r\n        #################################################\r\n\r\n        # To stop the monitoring thread, call the returned function\r\n        stop_monitoring()\r\n    \"\"\"\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Constantly checks and changes the priority of processes based on the provided parameters - Windows only",
    "version": "0.10",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/change_proc_priority"
    },
    "split_keywords": [
        "priority",
        "processes"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5f1b34862850e509006979c11c4d74f9271ba551e4463bf90df5533b2c12959d",
                "md5": "7979a12ca71a4bbaa29986c55a4e3c62",
                "sha256": "a3b50d945d0a94d43c0fe634d0ba332da6129948a3921e1b8ac7a198e7b8eb2c"
            },
            "downloads": -1,
            "filename": "change_proc_priority-0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7979a12ca71a4bbaa29986c55a4e3c62",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10733,
            "upload_time": "2023-05-31T07:37:45",
            "upload_time_iso_8601": "2023-05-31T07:37:45.923365Z",
            "url": "https://files.pythonhosted.org/packages/5f/1b/34862850e509006979c11c4d74f9271ba551e4463bf90df5533b2c12959d/change_proc_priority-0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1f839734ec43ceb2549c9945bed37bdf108186f7d8b9c1aecd5b71bc8fa24927",
                "md5": "98ebd3402e78914d10fbc11c7f038d69",
                "sha256": "01d5b8ce3c1861b4a687d552a7dfcf4b4b924d033ff5928f3f579a5410924f50"
            },
            "downloads": -1,
            "filename": "change_proc_priority-0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "98ebd3402e78914d10fbc11c7f038d69",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7668,
            "upload_time": "2023-05-31T07:37:48",
            "upload_time_iso_8601": "2023-05-31T07:37:48.468337Z",
            "url": "https://files.pythonhosted.org/packages/1f/83/9734ec43ceb2549c9945bed37bdf108186f7d8b9c1aecd5b71bc8fa24927/change_proc_priority-0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-31 07:37:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "change_proc_priority",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "change-proc-priority"
}
        
Elapsed time: 1.72887s