Skip to content

Commit

Permalink
Checking for error in file open
Browse files Browse the repository at this point in the history
There was a gap between checking for file existence and reading it. The file
could get deleted during that time. Added check for such cases so that file
deletion can be handled
Closes-Bug: 1566123

Change-Id: If9825744a8b89d74e96315c1d6982cee9efe256c
(cherry picked from commit f641b11)
  • Loading branch information
bansalnikhil committed May 10, 2016
1 parent 39ac2fe commit a447b5d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/nodemgr/vrouter_nodemgr/vrouter_process_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ def get_vrouter_process_info(self, proc_name):
if file.endswith(".ini"):
filename = \
'/etc/contrail/supervisord_vrouter_files/' + file
data = StringIO('\n'.join(line.strip()
try:
data = StringIO('\n'.join(line.strip()
for line in open(filename)))
except IOError:
msg = "This file does not exist anymore so continuing: "
sys.stderr.write(msg + filename + "\n")
continue
Config = ConfigParser.SafeConfigParser()
Config.readfp(data)
sections = Config.sections()
Expand Down

0 comments on commit a447b5d

Please sign in to comment.