diff --git a/src/wpsremote/resource_cleaner.py b/src/wpsremote/resource_cleaner.py index d9dfc44..965d18f 100644 --- a/src/wpsremote/resource_cleaner.py +++ b/src/wpsremote/resource_cleaner.py @@ -185,6 +185,8 @@ def read_from_file(self, filepath): self._spawned_process_cmd = json.loads(self._spawned_process_cmd) def write(self): + logger = logging.getLogger("Resource.write") + if self.filepath().exists(): self.filepath().remove() @@ -214,9 +216,13 @@ def write(self): else: config.set("DEFAULT", "spawned_process_cmd", "" ) - fp = self.filepath().open('wb') #todo: use file lock - config.write(fp) - fp.close() + try: + fp = self.filepath().open('wb') #todo: use file lock + config.write(fp) + fp.close() + except Exception as ex: + logger.error("could not create file '"+self.filepath()+"' due to: " + str(ex)) + raise ex("could not create file '"+self.filepath()+"'") def kill_spawned_process(self): """kill all spawned process generated by processbot"""