How to use the pysyncobj.FAIL_REASON 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 bakwc / PySyncObj / test_syncobj.py View on Github external
def onAddValue(res, err, info):
	assert res == 3
	assert err == FAIL_REASON.SUCCESS
	info['callback'] = True
github bakwc / PySyncObj / test_syncobj.py View on Github external
assert o.getCounter() == 400

	currRes = {}
	def onAdd(res, err):
		currRes[0] = err

	b1.addValue(50, callback=onAdd)

	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
	assert b1.getCounter() == 450
	assert b2.getCounter() == 450
	assert currRes.get(0) == FAIL_REASON.SUCCESS

	o1._destroy()
	o2._destroy()
	o3._destroy()

	b1._destroy()
	b2._destroy()
github zalando / patroni / patroni / dcs / raft.py View on Github external
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