code: def write_pid_file():
      
      pidfile = os.path.basename(sys.argv[0])[:-3] + '.pid'  # strip .py, add .pid
      with open(pidfile, 'w') as fh:
          fh.write("%d\n" % os.getpid())
          fh.close()
docs: Write a file with the PID of this server instance.
  
      Call when setting up a command line testserver.