code: def __open_pidfile(self, write=False):
          
          # if problem on opening or creating file it'll be raised to the caller:
          try:
              self.pre_log.append(("DEBUG",
                                   "Opening %s pid file: %s" % ('existing' if
                                                                os.path.exists(self.pid_filename)
                                                                else 'missing', self.pid_filename)))
              # Windows do not manage the rw+ mode,
              # so we must open in read mode first, then reopen it write mode...
              if not write and os.path.exists(self.pid_filename):
                  self.fpid = open(self.pid_filename, 'r+')
              else:
                  # If it doesn't exist too, we create it as void
                  self.fpid = open(self.pid_filename, 'w+')
          except Exception as exp:  # pylint: disable=broad-except
              self.exit_on_error("Error opening pid file: %s. Error: %s. "
                                 "Check the %s:%s account permissions to write this file."
                                 % (self.pid_filename, str(exp), self.user, self.group), exit_code=3)
docs: Open pid file in read or write mod
  
          :param write: boolean to open file in write mod (true = write)
          :type write: bool
          :return: None