pidfile
Logic around PID file
Classes:
-
Pidfile–PID file handler
Functions:
-
ensure_existing_path–Function to ensure if a given path exists on the disk
-
generate_random_pid_name–Function to generate a default PID file name with a random name
Pidfile
Pidfile(pid_name: str | None = None, pidfile_path: Path | str | None = None)
PID file handler
Constructor function to
Parameters:
-
(pid_namestr | None, default:None) –PID name
-
(pidfile_pathPath | str | None, default:None) –PID file path (folder where to store the PID file)
-
Documentation
Daemonizer
-
Samples
writers -
Core
Daemons
unixUNIXDaemon
-
Samples
Methods:
-
__repr__–Method to return a string representation of the class.
-
__str__–Method to return a string representation of the class.
-
delete–Method to delete the pidfile.
-
get_abs_path–Method to return the absolute path of the pidfile.
-
is_existing_file–Method to check if the pidfile exists.
-
read–Method to read the pid from the pidfile.
-
write–Method to write the pid to the pidfile.
__repr__
__repr__() -> str
Method to return a string representation of the class.
Returns:
-
str–String representation of the class.
__str__
__str__() -> str
Method to return a string representation of the class.
Returns:
-
str–String representation of the class.
delete
delete() -> bool
Method to delete the pidfile.
Returns:
-
bool–True if the pidfile was deleted, False otherwise.
get_abs_path
get_abs_path() -> str
Method to return the absolute path of the pidfile.
(simple concatenation between pid_path and pid_filename)
Returns:
-
str–The absolute path of the pidfile.
is_existing_file
is_existing_file() -> bool
Method to check if the pidfile exists.
Returns:
-
bool–True if the pidfile exists, False otherwise.
read
read() -> int
Method to read the pid from the pidfile.
Returns:
-
int–The pid read from the pidfile.
ensure_existing_path
Function to ensure if a given path exists on the disk
If not, create it and add it to the disk
Parameters:
-
(path_Path) –Path to be checked
Returns:
-
Nothing–None