Package flumotion :: Package common :: Module process
[hide private]

Module process

source code

utilities for interacting with processes


Version: $Rev: 6690 $

Functions [hide private]
 
startup(processType, processName, daemonize=False, daemonizeTo='/')
Prepare a process for starting, logging appropriate standarised messages.
source code
 
_daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null', directory='/')
This forks the current process into a daemon.
source code
 
_daemonizeHelper(processType, daemonizeTo='/', processName=None)
Daemonize a process, writing log files and PID files to conventional locations.
source code
 
_getPidPath(type, name=None)
Get the full path to the pid file for the given process type and name.
source code
str
writePidFile(type, name=None, file=None)
Write a pid file in the run directory, using the given process type and process name for the filename.
source code
str
_acquirePidFile(type, name=None)
Open a PID file for writing, using the given process type and process name for the filename.
source code
str
deletePidFile(type, name=None)
Delete the pid file in the run directory, using the given process type and process name for the filename.
source code
 
getPid(type, name=None)
Get the pid from the pid file in the run directory, using the given process type and process name for the filename.
source code
 
signalPid(pid, signum)
Send the given process a signal.
source code
 
termPid(pid)
Send the given process a TERM signal.
source code
 
killPid(pid)
Send the given process a KILL signal.
source code
 
checkPidRunning(pid)
Check if the given pid is currently running.
source code
 
waitPidFile(type, name=None)
Wait for the given process type and name to have started and created a pid file.
source code
 
waitForTerm()
Wait until we get killed by a TERM signal (from someone else).
source code
Function Details [hide private]

startup(processType, processName, daemonize=False, daemonizeTo='/')

source code 

Prepare a process for starting, logging appropriate standarised messages. First daemonizes the process, if daemonize is true.

_daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null', directory='/')

source code 

This forks the current process into a daemon. The stdin, stdout, and stderr arguments are file names that will be opened and be used to replace the standard file descriptors in sys.stdin, sys.stdout, and sys.stderr. These arguments are optional and default to /dev/null.

The fork will switch to the given directory.

_daemonizeHelper(processType, daemonizeTo='/', processName=None)

source code 

Daemonize a process, writing log files and PID files to conventional locations.

Parameters:
  • processType (str) - The process type, for example 'worker'. Used as part of the log file and PID file names.
  • daemonizeTo (str) - The directory that the daemon should run in.
  • processName (str) - The service name of the process. Used to disambiguate different instances of the same daemon.

writePidFile(type, name=None, file=None)

source code 

Write a pid file in the run directory, using the given process type and process name for the filename.

Returns: str
full path to the pid file that was written

_acquirePidFile(type, name=None)

source code 

Open a PID file for writing, using the given process type and process name for the filename. The returned file can be then passed to writePidFile after forking.

Returns: str
file object, open for writing

deletePidFile(type, name=None)

source code 

Delete the pid file in the run directory, using the given process type and process name for the filename.

Returns: str
full path to the pid file that was written

getPid(type, name=None)

source code 

Get the pid from the pid file in the run directory, using the given process type and process name for the filename.

Returns:
pid of the process, or None if not running or file not found.

signalPid(pid, signum)

source code 

Send the given process a signal.

Returns:
whether or not the process with the given pid was running

termPid(pid)

source code 

Send the given process a TERM signal.

Returns:
whether or not the process with the given pid was running

killPid(pid)

source code 

Send the given process a KILL signal.

Returns:
whether or not the process with the given pid was running

checkPidRunning(pid)

source code 

Check if the given pid is currently running.

Returns:
whether or not a process with that pid is active.

waitPidFile(type, name=None)

source code 

Wait for the given process type and name to have started and created a pid file.

Return the pid.