Commit c9b77a97 authored by Rafael Monnerat's avatar Rafael Monnerat

Set socket timeout for taskdistributions RPC calls

If socket timeout is not set the call can never receive a response and
system become locked for ever waiting a reply from task distribution server.
parent ffe0f754
......@@ -95,16 +95,21 @@ def patchRPCParser(error_handler):
parser_klass.feed = verbose_feed
class RPCRetry(object):
def __init__(self, proxy, retry_time, logger):
def __init__(self, proxy, retry_time, logger, timeout=120):
super(RPCRetry, self).__init__()
self._proxy = proxy
self._retry_time = retry_time
self._logger = logger
self.__rpc_lock = threading.Lock()
self.timeout = timeout
def _RPC(self, func_id, args=()):
with self.__rpc_lock:
default_timeout = socket.getdefaulttimeout()
socket.setdefaulttimeout(self.timeout)
try:
return getattr(self._proxy, func_id)(*args)
finally:
socket.setdefaulttimeout(default_timeout)
def _retryRPC(self, func_id, args=()):
retry_time = self._retry_time
......
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