hellysmile / async_retrying Goto Github PK
View Code? Open in Web Editor NEWSimple retrying for asyncio
Home Page: https://pypi.python.org/pypi/async_retrying
License: MIT License
Simple retrying for asyncio
Home Page: https://pypi.python.org/pypi/async_retrying
License: MIT License
https://docs.python.org/3.10/library/asyncio-task.html#generator-based-coroutines
Generally speaking the asyncio.coroutine decorator and yield from is no longer supported in Python 3.11 version of asyncio.
python==3.10
async_retrying==0.2.2
error:
TypeError: sleep() got an unexpected keyword argument 'loop'
This may be caused by the removal of loop parameter in later versions of python. Can you optimize it?
Source place:
@asyncio.coroutine
def callback(attempt, exc, args, kwargs, delay=None, *, loop):
if delay is None:
delay = callback.delay
yield from asyncio.sleep(attempt * delay, loop=loop)
return retry
Right now if is in debug mode, no attempts is tried
It is impossible to use kwargs = True
and immutable = True
because impossible to make copy.deepcopy
from loop.
I dont want to get logging massage, could you add a params like log=False
to close logger.warning msg。
if log: logger.warning( exc.__class__.__name__ + ' -> Attempts (%(attempt)d) are over for %(fn)r', # noqa context, exc_info=exc,
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'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.