Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def waitBinded(self):
"""
Waits until initialized (binded port).
If success - just returns.
If failed to initialized after conf.maxBindRetries - raise SyncObjException.
"""
self.__bindedEvent.wait()
if not self.__isInitialized:
raise SyncObjException('BindError')
error = None
event = threading.Event()
def rep_cb(res, err):
local.result = res
local.error = err
local.event.set()
if kwargs.get('_doApply', False):
return replicated(func)(self, *args, **kwargs)
else:
kwargs["callback"] = rep_cb
replicated(func)(self, *args, **kwargs)
res = local.event.wait(timeout = timeout)
if not res:
raise SyncObjException('Timeout')
if not local.error == 0:
raise SyncObjException(local.error)
return local.result
return newFunc
class local:
result = None
error = None
event = threading.Event()
def rep_cb(res, err):
local.result = res
local.error = err
local.event.set()
if kwargs.get('_doApply', False):
return replicated(func)(self, *args, **kwargs)
else:
kwargs["callback"] = rep_cb
replicated(func)(self, *args, **kwargs)
res = local.event.wait(timeout = timeout)
if not res:
raise SyncObjException('Timeout')
if not local.error == 0:
raise SyncObjException(local.error)
return local.result
return newFunc
shouldConnect = None
else:
shouldConnect = True
self.__nodes = []
for nodeAddr in self.__otherNodesAddrs:
self.__nodes.append(Node(self, nodeAddr, shouldConnect))
self.__raftNextIndex[nodeAddr] = self.__getCurrentLogIndex() + 1
self.__raftMatchIndex[nodeAddr] = 0
self.__needLoadDumpFile = True
self.__isInitialized = True
self.__bindedEvent.set()
except:
self.__bindRetries += 1
if self.__conf.maxBindRetries and self.__bindRetries >= self.__conf.maxBindRetries:
self.__bindedEvent.set()
raise SyncObjException('BindError')
logging.exception('failed to perform initialization')