Skip to content

Commit

Permalink
Catch exception in resource cleaner write function and log error
Browse files Browse the repository at this point in the history
  • Loading branch information
torse committed Jun 14, 2017
1 parent 14075ba commit d3deecf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/wpsremote/resource_cleaner.py
Expand Up @@ -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()

Expand Down Expand Up @@ -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"""
Expand Down

0 comments on commit d3deecf

Please sign in to comment.