Skip to content

Commit

Permalink
Ignore InotifyError exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jon-turney committed Mar 31, 2024
1 parent 56719ce commit 27a2ad8
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions calm/calm.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,29 +745,34 @@ def sigterm(signum, frame):
saw_events = False
depth = args.rel_area.count(os.path.sep) + 1

# It would be nice to use inotify.adaptor's timeout feature so
# we go at least a few seconds without events, to ensure that we
# don't start processing in the middle of a flurry of events.
# Unfortunately, that goes back to waiting for the full
# block_duration_s if timeout hasn't expired...
for event in i.event_gen(yield_nones=True):
if event is not None:
logging.debug("inotify event %s" % str(event))
saw_events = True
(_, type_names, path, filename) = event
if path.startswith(args.rel_area):
# ignore sha512.sum and modifications to setup.*
# files in the arch directory
if (filename != 'sha512.sum') and ((path.count(os.path.sep) > depth) or filename == ".touch"):
action |= Event.read_relarea
elif path.startswith(args.stagingdir):
action |= Event.read_uploads
elif (path.startswith(args.homedir)) and (filename == "!ready"):
action |= Event.read_uploads
else:
# None means no more events are currently available, so
# break to process actions
break
try:
# It would be nice to use inotify.adaptor's timeout feature so
# we go at least a few seconds without events, to ensure that we
# don't start processing in the middle of a flurry of events.
# Unfortunately, that goes back to waiting for the full
# block_duration_s if timeout hasn't expired...
for event in i.event_gen(yield_nones=True):
if event is not None:
logging.debug("inotify event %s" % str(event))
saw_events = True
(_, type_names, path, filename) = event
if path.startswith(args.rel_area):
# ignore sha512.sum and modifications to setup.*
# files in the arch directory
if (filename != 'sha512.sum') and ((path.count(os.path.sep) > depth) or filename == ".touch"):
action |= Event.read_relarea
elif path.startswith(args.stagingdir) and (filename != 'tmp'):
action |= Event.read_uploads
elif (path.startswith(args.homedir)) and (filename == "!ready"):
action |= Event.read_uploads
else:
# None means no more events are currently available, so
# break to process actions
break
except inotify.calls.InotifyError:
# can occur if a just created directory is (re)moved before
# we set a watch on it
pass

if not saw_events:
if time.time() > next_scan_time:
Expand Down

0 comments on commit 27a2ad8

Please sign in to comment.