code: def _write_pidfile(pidfile):
      
      pid = str(os.getpid())
      handle = open(pidfile, 'w')
      try:
          handle.write("%s\n" % pid)
      finally:
          handle.close()
docs: Write file with current process ID.