Commit 5cbe43a5 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Remove watcher pause file 1h past end time


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 3753b2cb
......@@ -1951,9 +1951,17 @@ def FormatTime(val):
return time.strftime("%F %T", time.localtime(val))
def ReadWatcherPauseFile(filename, now=None):
def ReadWatcherPauseFile(filename, now=None, remove_after=3600):
"""Reads the watcher pause file.
@type filename: string
@param filename: Path to watcher pause file
@type now: None, float or int
@param now: Current time as Unix timestamp
@type remove_after: int
@param remove_after: Remove watcher pause file after specified amount of
seconds past the pause end time
"""
if now is None:
now = time.time()
......@@ -1969,10 +1977,18 @@ def ReadWatcherPauseFile(filename, now=None):
try:
value = int(value)
except ValueError:
logging.warning(("Watcher pause file (%s) contains invalid value,"
" removing it"), filename)
RemoveFile(filename)
value = None
if value is not None:
if now > value:
# Remove file if it's outdated
if now > (value + remove_after):
RemoveFile(filename)
value = None
elif now > value:
value = None
return value
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment