Commit fa32d71f authored by Ivan Tyagov's avatar Ivan Tyagov

It safer to pass proxy and function_id so we avoid httplib.ResponseNotReady

by trying reconnect before server keep-alive ends and the socket closes.
parent 0f375bda
...@@ -60,14 +60,17 @@ def sigterm_handler(signal, frame): ...@@ -60,14 +60,17 @@ def sigterm_handler(signal, frame):
signal.signal(signal.SIGTERM, sigterm_handler) signal.signal(signal.SIGTERM, sigterm_handler)
def safeRpcCall(function, *args): def safeRpcCall(proxy, function_id, *args):
# XXX: this method will try infinitive calls to backend # XXX: this method will try infinitive calls to backend
# this can cause testnode to looked "stalled" # this can cause testnode to looked "stalled"
retry = 64 retry = 64
while True: while True:
try: try:
# it safer to pass proxy and function_id so we avoid httplib.ResponseNotReady
# by trying reconnect before server keep-alive ends and the socket closes
function = getattr(proxy, function_id)
return function(*args) return function(*args)
except (socket.error, xmlrpclib.ProtocolError), e: except (socket.error, xmlrpclib.ProtocolError, xmlrpclib.Fault), e:
logging.warning(e) logging.warning(e)
pprint.pprint(args, file(function._Method__name, 'w')) pprint.pprint(args, file(function._Method__name, 'w'))
time.sleep(retry) time.sleep(retry)
...@@ -197,7 +200,6 @@ branch = %(branch)s ...@@ -197,7 +200,6 @@ branch = %(branch)s
log('Retrying install') log('Retrying install')
retry_software = False retry_software = False
previous_revision = revision previous_revision = revision
portal_url = config['test_suite_master_url'] portal_url = config['test_suite_master_url']
test_result_path = None test_result_path = None
test_result = (test_result_path, revision) test_result = (test_result_path, revision)
...@@ -207,9 +209,8 @@ branch = %(branch)s ...@@ -207,9 +209,8 @@ branch = %(branch)s
portal = xmlrpclib.ServerProxy("%s%s" % portal = xmlrpclib.ServerProxy("%s%s" %
(portal_url, 'portal_task_distribution'), (portal_url, 'portal_task_distribution'),
allow_none=1) allow_none=1)
master = portal assert safeRpcCall(portal, "getProtocolRevision") == 1
assert safeRpcCall(master.getProtocolRevision) == 1 test_result = safeRpcCall(portal, "createTestResult",
test_result = safeRpcCall(master.createTestResult,
config['test_suite'], revision, [], config['test_suite'], revision, [],
False, test_suite_title, False, test_suite_title,
config['test_node_title'], config['project_title']) config['test_node_title'], config['project_title'])
...@@ -289,7 +290,7 @@ branch = %(branch)s ...@@ -289,7 +290,7 @@ branch = %(branch)s
process_group_pid_set.remove(run_test_suite.pid) process_group_pid_set.remove(run_test_suite.pid)
except SubprocessError, e: except SubprocessError, e:
if remote_test_result_needs_cleanup: if remote_test_result_needs_cleanup:
safeRpcCall(master.reportTaskFailure, safeRpcCall(portal, "reportTaskFailure",
test_result_path, e.status_dict, config['test_node_title']) test_result_path, e.status_dict, config['test_node_title'])
time.sleep(DEFAULT_SLEEP_TIMEOUT) time.sleep(DEFAULT_SLEEP_TIMEOUT)
continue continue
......
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