Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@aiomisc.asyncbackoff(0.5, 0.5, 0, Exception, max_tries=max_tries)
async def test():
nonlocal mana
mana += 1
raise ValueError("RETRY")
@aiomisc.asyncbackoff(None, 1, 0, Exception)
async def test():
nonlocal mana
mana += 1
await asyncio.sleep(0.2)
raise ValueError("RETRY")
@aiomisc.asyncbackoff(0.15, None, 0, Exception)
async def test():
nonlocal mana
mana += 1
await asyncio.sleep(max_sleep - (mana - 1) * 0.1)
@aiomisc.asyncbackoff(0.10, 0.5)
async def test():
nonlocal mana
if mana < 500:
mana += 1
await asyncio.sleep(0.05)
raise ValueError("Not enough mana")
@aiomisc.asyncbackoff(0.10, 1, None, Exception)
async def test():
nonlocal mana
if mana < 5:
mana += 1
await asyncio.sleep(0.05)
raise ValueError("Not enough mana")
@aiomisc.asyncbackoff(0.5, 0.5, 0, Exception)
async def test():
nonlocal mana
if mana < 500:
mana += 1
await asyncio.sleep(5)
raise ValueError("Not enough mana")
def test_values(loop):
with pytest.raises(ValueError):
aiomisc.asyncbackoff(-1, 1)
with pytest.raises(ValueError):
aiomisc.asyncbackoff(0, -1)
with pytest.raises(ValueError):
aiomisc.asyncbackoff(0, 0, -0.1)
with pytest.raises(TypeError):
aiomisc.asyncbackoff(0, 0)(lambda x: None)
def test_values(loop):
with pytest.raises(ValueError):
aiomisc.asyncbackoff(-1, 1)
with pytest.raises(ValueError):
aiomisc.asyncbackoff(0, -1)
with pytest.raises(ValueError):
aiomisc.asyncbackoff(0, 0, -0.1)
with pytest.raises(TypeError):
aiomisc.asyncbackoff(0, 0)(lambda x: None)
def test_values(loop):
with pytest.raises(ValueError):
aiomisc.asyncbackoff(-1, 1)
with pytest.raises(ValueError):
aiomisc.asyncbackoff(0, -1)
with pytest.raises(ValueError):
aiomisc.asyncbackoff(0, 0, -0.1)
with pytest.raises(TypeError):
aiomisc.asyncbackoff(0, 0)(lambda x: None)