Skip to content

retrying #88

@itaybz

Description

@itaybz

using the retrying package. How do I use it for retrying, and if the retries ends without a successful match, the code block leaves?

import random
from retrying import retry

@retry(wait_fixed=500, stop_max_delay=5000 )
def do_something_unreliable():
    result = random.randint(0, 10)
    print result
    if result != 11:
        raise IOError("Broken")
    else:
        return True

print do_something_unreliable()

I want the the raise IOError to be replaced with an option of returning, say, False

In other words, I want to use this decorator, in case of actual values is different than expected, while the actual is created frequently from other function

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions