Coder Social home page Coder Social logo

retrying-async's People

Contributors

blagowtf avatar cailiang9 avatar lwithd avatar lxl0928 avatar rightx2 avatar

Stargazers

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

Watchers

 avatar

retrying-async's Issues

python 3.7.5 运行示例有问题

`import asyncio

from retrying_async import retry

counter = 0

@Retry(attempts=3, delay=3)
async def fn():
global counter

counter += 1

if counter == 1:
    raise RuntimeError

async def main():
await fn()

loop = asyncio.get_event_loop()

loop.run_until_complete(main())

assert counter == 2

loop.close()
`
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/WorkSpace/bili_huahuo_spider/tests/test_retry.py", line 28, in
loop.run_until_complete(main())
File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete
return future.result()
File "/home/WorkSpace/bili_huahuo_spider/tests/test_retry.py", line 23, in main
await fn()
File "/home/.virtualenvs/bili_huahuo_spider/lib/python3.7/site-packages/retrying_async.py", line 169, in wrapped
raise fallback from exc
retrying_async.RetryError
sys:1: RuntimeWarning: coroutine 'fn' was never awaited

Getting CancelledError when using retry decorator

I am using the retry decorator with an async method:

import asyncio

from retrying_async import retry


@retry(attempts='infinite', delay=3)
async def a():
    await b()
    while True:
        try:
            print("Hi")
            await asyncio.sleep(1)
        except Exception as exception:
            print(type(exception))
            print("Exception encountered")
            raise exception


async def b():
    print("hi")


if __name__ == "__main__":
    asyncio.run(a())

Getting this exception here:

Hi
Hi
Hi
Hi
Hi
Hi
Hi
Hi
Hi
Hi
Hi
Hi
Hi
<class 'concurrent.futures._base.CancelledError'>
Exception encountered

Any suggestions here ? This does not happen if I remove the retry decorator.

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.