Giter VIP home page Giter VIP logo

async_retrying's People

Contributors

hellysmile avatar kvirt avatar litwisha avatar mikenemkov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

async_retrying's Issues

python== 3.10 has loop error

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

Kwargs loop immutable fail

It is impossible to use kwargs = True and immutable = True because impossible to make copy.deepcopy from loop.

add a params to close logging

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,

Retry as context_manager

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'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.