Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def onAddValue(res, err, info):
assert res == 3
assert err == FAIL_REASON.SUCCESS
info['callback'] = True
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()
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