def measure_clock_skew(label, host):
cmd = ['ntpdate', '-q', '-p', '8', host]
extra_logger.info('[%s] Starting network calibration with %s', label, ' '.join(cmd))
skew = Clockskew(label, cmd)
# TODO: search PATH for this?
process = reactor.spawnProcess(skew, '/usr/sbin/ntpdate', cmd, {})
# process = reactor.spawnProcess(skew, '/bin/sleep', ['sleep', '2'], {})
t = float(os.environ.get('UNIVERSE_NTPDATE_TIMEOUT', 20))
def timeout():
if process.pid:
logger.error('[%s] %s call timed out after %ss; killing the subprocess. This is ok, but you could have more accurate timings by enabling UDP port 123 traffic to your env. (Alternatively, you can try increasing the timeout by setting environment variable UNIVERSE_NTPDATE_TIMEOUT=10.)', label, ' '.join(cmd), t)
process.signalProcess(signal.SIGKILL)
process.reapProcess()
# TODO: make this part of the connection string
reactor.callLater(t, timeout)
return skew.deferred
评论列表
文章目录