Skip to content

Commit 50dfc8b

Browse files
committed
Update README.md
1 parent 7b4373f commit 50dfc8b

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ while solving various problems a developer may face among:
1616
- Allow stdout/stderr stream output to be redirected to callback functions / output queues / files so you get to handle output in your application while commands are running
1717
- Callback to optional stop check so we can stop execution from outside command_runner
1818
- Callback with optional process information so we get to control the process from outside command_runner
19+
- Callback once we're finished to easen thread usage
20+
- Optional process priority and io_priority settings
1921
- System agnostic functionality, the developer shouldn't carry the burden of Windows & Linux differences
2022
- Optional Windows UAC elevation module compatible with CPython, PyInstaller & Nuitka
2123
- Optional Linux sudo elevation compatible with CPython, PyInstaller & Nuitka
@@ -334,7 +336,7 @@ def callback_function(string):
334336
exit_code, output = command_runner('ping 127.0.0.1', stdout=callback_function, method='poller')
335337
```
336338

337-
#### Stop_on
339+
#### stop_on
338340

339341
In some situations, you want a command to be aborted on some external triggers.
340342
That's where `stop_on` argument comes in handy.
@@ -402,6 +404,18 @@ def do_something():
402404
exit_code, output = command_runner('ping 127.0.0.1', on_exit=do_something)
403405
```
404406

407+
### Process and IO priority
408+
`command_runner` can set it's subprocess priority to 'low', 'medium' or 'high', which translate to 15, 0, -15 niceness on Linux and BELOW_NORMAL_PRIORITY_CLASS and HIGH_PRIORITY_CLASS in Windows.
409+
410+
The same applies to IO bound priority.
411+
412+
Example:
413+
```python
414+
from command_runner import command_runner
415+
416+
exit_code, output = command_runner('some_intensive_process', priority='low', io_priority='high')
417+
```
418+
405419
#### Other arguments
406420

407421
`command_runner` takes **any** argument that `subprocess.Popen()` would take.
@@ -423,27 +437,15 @@ It also uses the following standard arguments:
423437
- process_callback (function): Optional function that will take command_runner spawned process as argument, in order to deal with process info outside of command_runner
424438
- split_streams (bool): Split stdout and stderr into two separate results
425439
- silent (bool): Allows to disable command_runner's internal logs, except for logging.DEBUG levels which for obvious reasons should never be silenced
440+
- priority (str): Allows to set CPU bound process priority (takes 'low', 'normal' or 'high' parameter)
441+
- io_priority (str): Allows to set IO priority for process (takes 'low', 'normal' or 'high' parameter)
426442
- close_fds (bool): Like Popen, defaults to True on Linux and False on Windows
427443
- universal_newlines (bool): Like Popen, defaults to False
428444
- creation_flags (int): Like Popen, defaults to 0
429445
- bufsize (int): Like Popen, defaults to 16384. Line buffering (bufsize=1) is deprecated since Python 3.7
430446

431447
**Note that ALL other subprocess.Popen arguments are supported, since they are directly passed to subprocess.**
432448

433-
### logging
434-
435-
Even muted, `command_runner` will still log errors.
436-
If you want to completely mute `command_runner`, you will have to set it's logger instance to `logger.CRITICAL` level, since this level is never called.
437-
438-
Example of entirely muted `command_runner` execution:
439-
```
440-
rom command_runner import command_runner
441-
import logging
442-
443-
logging.getLogger("command_runner").setLevel(logging.CRITICAL)
444-
445-
err_code, stdout, stderr = command_runner("ping 127.0.0.1", timeout=1, method='monitor', live_output=False, stdout=False, stderr=False, split_streams=True)
446-
```
447449

448450
## UAC Elevation / sudo elevation
449451

0 commit comments

Comments
 (0)