Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dynamic configuration for stop & wait conditions #325

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gtors
Copy link

@gtors gtors commented Jul 16, 2021

This PR adds the ability to configure @retry based on the attributes of a class instance

Simplified use case:

class Service:
   def __init__(self, tries):
       self.tries = tries

   @retry(
       retry=retry_if_exception_type(IOError),
       stop=stop_after_attempts(attempts=from_attr("tries")),
   )
   def call_other_service(self):
       ...


def load_config_from_file_system():
   ...


def main():
   config = load_config_from_file_system()
   serivice = Service(config.service.retry_attempts)
   serivice.call_other_service()

@mergify
Copy link
Contributor

mergify bot commented Jul 16, 2021

⚠️ No release notes detected. Please make sure to use reno to add a changelog entry.

@penguinolog
Copy link
Contributor

looks like it's job for descriptor, not normal decorator. In case of descriptor, owner class will be registered during class construction and owner instance will be sent to Retrying instance. But this is serious change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants