Skip to content

Commit d232a68

Browse files
committed
Add heartbeat usage
1 parent 4f30cdd commit d232a68

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ while solving various problems a developer may face among:
2121
- System agnostic functionality, the developer shouldn't carry the burden of Windows & Linux differences
2222
- Optional Windows UAC elevation module compatible with CPython, PyInstaller & Nuitka
2323
- Optional Linux sudo elevation compatible with CPython, PyInstaller & Nuitka
24+
- Optional heartbeat for command execution
2425

25-
It is compatible with Python 2.7+, tested up to Python 3.11 (backports some newer Python 3.5 functionality) and is tested on both Linux and Windows.
26+
It is compatible with Python 2.7+, tested up to Python 3.12 (backports some newer functionality to Python 3.5) and is tested on both Linux and Windows.
2627
It is also compatible with PyPy Python implementation.
2728
...and yes, keeping Python 2.7 compatibility has proven to be quite challenging.
2829

@@ -435,6 +436,16 @@ from command_runner import command_runner
435436
exit_code, output = command_runner('some_intensive_process', priority='low', io_priority='high')
436437
```
437438

439+
### Heartbeat
440+
When running long commands, one might want to know that the program is still running.
441+
The following example will log a message every hour stating that we're still running our command
442+
443+
```python
444+
from command_runner import command_runner
445+
446+
exit_code, output = command_runner('/some/long/command', timeout=None, heartbeat=3600)
447+
```
448+
438449
#### Other arguments
439450

440451
`command_runner` takes **any** argument that `subprocess.Popen()` would take.
@@ -460,6 +471,7 @@ It also uses the following standard arguments:
460471
- silent (bool): Allows to disable command_runner's internal logs, except for logging.DEBUG levels which for obvious reasons should never be silenced
461472
- priority (str): Allows to set CPU bound process priority (takes 'low', 'normal' or 'high' parameter)
462473
- io_priority (str): Allows to set IO priority for process (takes 'low', 'normal' or 'high' parameter)
474+
- heartbeat (int): Optional seconds on which command runner should log a heartbeat message
463475
- close_fds (bool): Like Popen, defaults to True on Linux and False on Windows
464476
- universal_newlines (bool): Like Popen, defaults to False
465477
- creation_flags (int): Like Popen, defaults to 0

0 commit comments

Comments
 (0)