Beispiel #1
0
    def _writing_thread(self):  # pragma: no cover
        while not self.machine.thread_stopper.is_set():
            if not self._dirty.wait(1):
                continue
            self._dirty.clear()

            data = copy.deepcopy(self.data)
            self.debug_log("Writing %s to: %s", self.name, self.filename)
            # save data
            FileManager.save(self.filename, data)
Beispiel #2
0
    def _writing_thread(self):  # pragma: no cover
        # prevent early writes at start-up
        time.sleep(self.min_wait_secs)
        while not self.machine.thread_stopper.is_set():
            if not self._dirty.wait(1):
                continue
            self._dirty.clear()

            data = copy.deepcopy(self.data)
            self.debug_log("Writing %s to: %s", self.name, self.filename)
            # save data
            FileManager.save(self.filename, data)
            # prevent too many writes
            time.sleep(self.min_wait_secs)

        # if dirty write data one last time during shutdown
        if self._dirty.is_set():
            FileManager.save(self.filename, data)
Beispiel #3
0
 def save_file(self, file_name, file_contents):
     """Save file."""
     self.log.info("Writing file: %s", file_name)
     FileManager.save(file_name, file_contents)