interface documentation

Manages a file that remembers a process ID.

Method __enter__ Enter a context using this PIDFile.
Method __exit__ Exit a context using this PIDFile.
Method isRunning Determine whether there is a running process corresponding to the PID in this PID file.
Method read Read the process ID stored in this PID file.
Method remove Remove this PID file.
Method writeRunningPID Store the PID of the current process in this PID file.
def __enter__() -> IPIDFile: (source)

Enter a context using this PIDFile.

Writes the PID file with the PID of the running process.

Raises
AlreadyRunningErrorA process corresponding to the PID in this PID file is already running.
def __exit__(excType: Optional[Type[BaseException]], excValue: Optional[BaseException], traceback: Optional[TracebackType]) -> Optional[bool]: (source)

Exit a context using this PIDFile.

Removes the PID file.

def isRunning() -> bool: (source)

Determine whether there is a running process corresponding to the PID in this PID file.

Returns
boolTrue if this PID file contains a PID and a process with that PID is currently running; false otherwise.
Raises
EnvironmentErrorIf this PID file cannot be read.
InvalidPIDFileErrorIf this PID file's content is invalid.
StalePIDFileErrorIf this PID file's content refers to a PID for which there is no corresponding running process.
def read() -> int: (source)

Read the process ID stored in this PID file.

Returns
intThe contained process ID.
Raises
NoPIDFoundIf this PID file does not exist.
EnvironmentErrorIf this PID file cannot be read.
ValueErrorIf this PID file's content is invalid.
def remove(): (source)

Remove this PID file.

Raises
EnvironmentErrorIf this PID file cannot be removed.
def writeRunningPID(): (source)

Store the PID of the current process in this PID file.

Raises
EnvironmentErrorIf this PID file cannot be written.