parameters: (self, pidPath)
docstring: pidPath - full path/filename where pid for running application is to be
                    stored.  Often this is ./var/<pgmname>.pid
docstring_summary: pidPath - full path/filename where pid for running application is to be
                    stored.  Often this is ./var/<pgmname>.pid
docstring_tokens: pidPath - full path / filename where pid for running application is to be stored . Often this is . / var / <pgmname > . pid
function: def __init__(self, pidPath):
          '''
          pidPath - full path/filename where pid for running application is to be
                    stored.  Often this is ./var/<pgmname>.pid
          '''
          from os import kill
          self.pidPath=pidPath
          #
          # See if pidFile exists
          #
          if os.path.exists(pidPath):
              #
              # Make sure it is not a "stale" pidFile
              #
              try:
                  pid=int(open(pidPath, 'r').read().strip())
                  #
                  # Check list of running pids, if not running it is stale so
                  # overwrite
                  #
                  try:
                      kill(pid, 0)
                      pidRunning = 1
                  except OSError:
                      pidRunning = 0
                  if pidRunning:
                      self.lasterror=True
                  else:
                      self.lasterror=False
              except:
                  self.lasterror=False
          else:
              self.lasterror=False
  
          if not self.lasterror:
              #
              # Write my pid into pidFile to keep multiple copies of program from
              # running.
              #
              fp=open(pidPath, 'w')
              fp.write(str(os.getpid()))
              fp.close()
function_tokens: def __init__ ( self , pidPath ) : from os import kill self . pidPath = pidPath # # See if pidFile exists # if os . path . exists ( pidPath ) : # # Make sure it is not a "stale" pidFile # try : pid = int ( open ( pidPath , 'r' ) . read ( ) . strip ( ) ) # # Check list of running pids, if not running it is stale so # overwrite # try : kill ( pid , 0 ) pidRunning = 1 except OSError : pidRunning = 0 if pidRunning : self . lasterror = True else : self . lasterror = False except : self . lasterror = False else : self . lasterror = False if not self . lasterror : # # Write my pid into pidFile to keep multiple copies of program from # running. # fp = open ( pidPath , 'w' ) fp . write ( str ( os . getpid ( ) ) ) fp . close ( )