From fbb7944851b249e473dab0b350970a4695b04315 Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Tue, 7 Aug 2012 23:25:57 +0000 Subject: xenapi: reduce polling interval for agent Communicating with the agent requires polling for a response. The operation uses xenstore, which is lightweight, yet the interval in between polls was 3 seconds. This would cause longer than necessary sleeps when an instance was booting making the overall boot slower. Change-Id: I560c05887128f1a0e29228e859cca25ded4eceec --- plugins/xenserver/xenapi/etc/xapi.d/plugins/agent | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'plugins/xenserver') diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent b/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent index fa1558bd7..a31097262 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/agent @@ -206,22 +206,22 @@ def _wait_for_agent(self, request_id, arg_dict): arg_dict["path"] = "data/guest/%s" % request_id arg_dict["ignore_missing_path"] = True start = time.time() - while True: - if time.time() - start > AGENT_TIMEOUT: - # No response within the timeout period; bail out - # First, delete the request record - arg_dict["path"] = "data/host/%s" % request_id - xenstore.delete_record(self, arg_dict) - raise TimeoutError(_("TIMEOUT: No response from agent within" - " %s seconds.") % AGENT_TIMEOUT) + while time.time() - start < AGENT_TIMEOUT: ret = xenstore.read_record(self, arg_dict) # Note: the response for None with be a string that includes # double quotes. if ret != '"None"': # The agent responded return ret - else: - time.sleep(3) + + time.sleep(.5) + + # No response within the timeout period; bail out + # First, delete the request record + arg_dict["path"] = "data/host/%s" % request_id + xenstore.delete_record(self, arg_dict) + raise TimeoutError(_("TIMEOUT: No response from agent within" + " %s seconds.") % AGENT_TIMEOUT) if __name__ == "__main__": -- cgit