How to use the pysyncobj.FAIL_REASON.SUCCESS function in pysyncobj

To help you get started, we’ve selected a few pysyncobj examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zalando / patroni / tests / test_raft.py View on Github external
def test_retry(self):
        return_values = [FAIL_REASON.QUEUE_FULL, FAIL_REASON.SUCCESS, FAIL_REASON.REQUEST_DENIED]

        def test(callback):
            callback(True, return_values.pop(0))
        self.assertTrue(self.so.retry(test))
        self.assertFalse(self.so.retry(test))
github bakwc / PySyncObj / benchmarks / testobj.py View on Github external
def clbck(res, err):
    global _g_error, _g_success
    if err == FAIL_REASON.SUCCESS:
        _g_success += 1
    else:
        _g_error += 1
        _g_errors[err] += 1
github bakwc / PySyncObj / benchmarks / testobj_delay.py View on Github external
def clbck(res, err):
    global _g_error, _g_success, _g_delays
    if err == FAIL_REASON.SUCCESS:
        _g_success += 1
        callTime, recvTime = res
        delay = time.time() - callTime
        _g_delays.append(delay)
    else:
        _g_error += 1
        _g_errors[err] += 1
github bakwc / PySyncObj / test_syncobj.py View on Github external
doTicks(objs + roObjs, 5.0, stopFunc=lambda: o1.getCounter() == 450 and \
												 b1.getCounter() == 450 and \
												 b2.getCounter() == 450 and
												 currRes.get(0) == FAIL_REASON.SUCCESS)
	assert o1.getCounter() == 450
github bakwc / PySyncObj / test_syncobj3.py View on Github external
def onAddValue(res, err, info):
	assert res == 3
	assert err == FAIL_REASON.SUCCESS
	info['callback'] = True
github zalando / patroni / patroni / dcs / raft.py View on Github external
event = threading.Event()
        ret = {'result': None, 'error': -1}

        def callback(result, error):
            ret.update(result=result, error=error)
            event.set()

        kwargs['callback'] = callback
        timeout = kwargs.pop('timeout', None) or self.__retry_timeout
        deadline = timeout and time.time() + timeout

        while True:
            event.clear()
            func(*args, **kwargs)
            event.wait(timeout)
            if ret['error'] == FAIL_REASON.SUCCESS:
                return ret['result']
            elif ret['error'] == FAIL_REASON.REQUEST_DENIED:
                break
            elif deadline:
                timeout = deadline - time.time()
                if timeout <= 0:
                    break
            time.sleep(1)
        return False
github bakwc / PySyncObj / syncobj3_ut.py View on Github external
def onAddValue(res, err, info):
	assert res == 3
	assert err == FAIL_REASON.SUCCESS
	info['callback'] = True
github mosuka / cockatrice / cockatrice / index_core.py View on Github external
def _SyncObj__utilityCallback(self, res, err, conn, cmd, node):
        cmdResult = 'FAIL'
        if err == FAIL_REASON.SUCCESS:
            cmdResult = 'SUCCESS'
        conn.send(cmdResult + ' ' + cmd + ' ' + node)
github mosuka / cockatrice / cockatrice / util / raft.py View on Github external
def _SyncObj__utilityCallback(self, res, err, conn, cmd, node):
        cmdResult = 'FAIL'
        if err == FAIL_REASON.SUCCESS:
            cmdResult = 'SUCCESS'
        conn.send(cmdResult + ' ' + cmd + ' ' + node)