-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
My proposal is to make retry function possible to be used as context manager which wraps original function in the with block:
>>> from asynctest import CoroutineMock
>>> async def case1():
... fn = CoroutineMock(side_effect=[RuntimeError, 'success'])
... return await fn()
>>> async def case2():
... fn = CoroutineMock(side_effect=[RuntimeError, 'success'])
... with retry(fn) as wrapped:
... return await wrapped()
>>> asyncio.get_event_loop().run_until_complete(case1())
RuntimeError:
...
>>> asyncio.get_event_loop().run_until_complete(case2())
'success'Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels