def createPid(pidPath='/var/run'):
 import os
 import sys
 currentPid = os.getpid()
 if (not currentPid):
  print 'Could not find PID'
  sys.exit()
 (scriptFilename, _) = os.path.splitext(os.path.basename(sys.argv[0]))
 pidFile = ('%s.pid' % scriptFilename)
 pidFilePath = os.path.join(pidPath, pidFile)
 with open(pidFilePath, 'w') as fileh:
  fileh.write(currentPid)

def createPid ( pidPath = '/var/run' ) : import os import sys currentPid = os . getpid ( ) if ( not currentPid ) : print 'Could not find PID' sys . exit ( ) ( scriptFilename , _ ) = os . path . splitext ( os . path . basename ( sys . argv [ 0 ] ) ) pidFile = ( '%s.pid' % scriptFilename ) pidFilePath = os . path . join ( pidPath , pidFile ) with open ( pidFilePath , 'w' ) as fileh : fileh . write ( currentPid )
creates pid file for process .