Title
provide.foundation.process.title
¶
TODO: Add module docstring.
Functions¶
get_process_title
¶
Get the current process title.
Automatically returns None in test mode (via @skip_in_test_mode decorator) to prevent test interference.
Returns:
| Type | Description |
|---|---|
str | None
|
The current process title, or None if setproctitle is not available |
str | None
|
or running in test mode |
Example
from provide.foundation.process import get_process_title, set_process_title set_process_title("my-process") True get_process_title() 'my-process'
Source code in provide/foundation/process/title.py
has_setproctitle
¶
Check if setproctitle is available.
Returns:
| Type | Description |
|---|---|
bool
|
True if setproctitle is available, False otherwise |
Example
from provide.foundation.process import has_setproctitle if has_setproctitle(): ... # Use process title features ... pass
Source code in provide/foundation/process/title.py
set_process_title
¶
Set the process title visible in system monitoring tools.
The process title is what appears in ps, top, htop, and other system monitoring tools. This is useful for identifying processes, especially in multi-process applications or long-running services.
Automatically disabled in test mode (via @skip_in_test_mode decorator) to prevent interference with test isolation and parallel test execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
The title to set for the current process |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the title was set successfully (or skipped in test mode), |
bool
|
False if setproctitle is not available |
Example
from provide.foundation.process import set_process_title set_process_title("my-worker-process") True
Process will now show as "my-worker-process" in ps/top¶
Source code in provide/foundation/process/title.py
set_process_title_from_argv
¶
Set process title from argv, preserving the invoked command name.
Extracts the command name from sys.argv[0] (including symlinks) and formats it with the remaining arguments to create a clean process title.
This handles symlinks correctly - if you have a symlink 'whatever' pointing to 'pyvider', and run 'whatever run --config foo.yml', the process title will be 'whatever run --config foo.yml'.
Automatically disabled in test mode (via @skip_in_test_mode decorator) to prevent interference with test isolation and parallel test execution.
Returns:
| Type | Description |
|---|---|
bool
|
True if the title was set successfully (or skipped in test mode), |
bool
|
False if setproctitle is not available |
Example
If invoked as: pyvider run --config foo.yml¶
from provide.foundation.process import set_process_title_from_argv set_process_title_from_argv() True
Process will show as "pyvider run --config foo.yml" in ps/top¶
If invoked via symlink: whatever run¶
(where whatever -> pyvider)¶
set_process_title_from_argv() True
Process will show as "whatever run" in ps/top¶