def write_pid_file(self): with open(PID_PATH,'w+') as f: os.fchmod(f.fileno(), 0666) f.write(str(self.pid)) f.flush()