Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 13 additions & 23 deletions usr/lib/python3/dist-packages/sdwdate/sdwdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,29 +858,19 @@ def wait_sleep(self):

self.unixtime_before_sleep = int(time.time())

# Using sh sleep in place of
# python's time.sleep(self.sleep_time_seconds).
# The latter uses the system clock for its inactive state time.
# It becomes utterly confused when sclockadj is running.
#
# Reverting back to python's time.sleep. Python's sleep no longer
# seems affected by clock jumps.
#
#sleep_cmd = ("sleep" +
# " " +
# str(self.sleep_time_seconds) +
# "." +
# str(nanoseconds))
#message = "running command: " + sleep_cmd
#LOGGER.info(message)
#
## Avoid Popen shell=True.
#sleep_cmd = shlex.split(sleep_cmd)
#
#global sleep_process
#sleep_process = Popen(sleep_cmd)
#sleep_process.wait()
time.sleep(self.sleep_time_seconds + nanoseconds)
## Send periodic watchdog notifications during sleep to prevent
## systemd from killing the service due to watchdog timeout.
watchdog_interval_seconds = 60
## nanoseconds is an integer in range [0, 999999999) and must be
## converted to fractional seconds before adding to sleep duration.
total_sleep = self.sleep_time_seconds + (nanoseconds / 1000000000)
slept = 0
while slept < total_sleep:
remaining = total_sleep - slept
chunk = min(watchdog_interval_seconds, remaining)
time.sleep(chunk)
slept += chunk
SDNOTIFY_OBJECT.notify("WATCHDOG=1")


def check_clock_skew(self):
Expand Down