Package glue :: Module pidfile
[hide private]
[frames] | no frames]

Module pidfile

source code

A simple module for acquiring pidfile locks (e.g., for use by daemons).

Copyright (C) 2010 by Peter F. Couvares, Syracuse University mailto: pfcouvar@syr.edu

Functions [hide private]
 
confirm_lock(lockfile)
Confirm that the given lockfile contains our pid.
source code
 
get_lock(lockfile)
Tries to write a lockfile containing the current pid.
source code
Variables [hide private]
  __package__ = 'glue'
Function Details [hide private]

confirm_lock(lockfile)

source code 

Confirm that the given lockfile contains our pid. Should be entirely unecessary, but paranoia always served me well.

get_lock(lockfile)

source code 

Tries to write a lockfile containing the current pid. Excepts if the lockfile already contains the pid of a running process.

Although this should prevent a lock from being granted twice, it can theoretically deny a lock unjustly in the unlikely event that the original process is gone but another unrelated process has been assigned the same pid by the OS.