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

Added minimal logging #6

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

Added minimal logging #6

wants to merge 1 commit into from

Conversation

frnhr
Copy link

@frnhr frnhr commented Mar 27, 2023

Something like this for the issue #3 ?

@frnhr frnhr closed this Mar 27, 2023
@frnhr frnhr reopened this Mar 27, 2023
Copy link

@lewis-wf lewis-wf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels pretty essential - currently got a problem where having a logger would be handy.

Copy link

@PamelaM PamelaM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good addition, but I had two suggestions that block me from approving this PR. (you could always convince me, neither of them are [bug/blocking], much less [BLOCKING] -- the latter of which I've only used twice when I ran into code that would instantly corrupt data)

@@ -268,6 +271,7 @@ def call(self, fn, *args, **kwargs):
raise RetryError(attempt)
else:
sleep = self.wait(attempt_number, delay_since_first_attempt_ms)
self._logger.info(f"Retrying in {sleep / 1000.0:.2f} seconds.")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] This line should be below the if self._wait_jitter_max: clause so that it reflects the actual wait time.

Copy link
Author

@frnhr frnhr Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: NM, I read it to quickly 😁. Moving below 👍

@@ -110,6 +111,7 @@ def __init__(
self._wait_jitter_max = 0 if wait_jitter_max is None else wait_jitter_max
self._before_attempts = before_attempts
self._after_attempts = after_attempts
self._logger = logging.getLogger(__name__) if logger is None else logger
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[blocking] This is okay, but I hate having a library change behavior wrt logging.

Maybe something like:

if logger in (True, None):
    self._logger = logging.getLogger(__name__)
    if logger is None:
       # -- Turn this into a Null Logger
        self._logger.addHandler(logging.NullHandler()) 
        self._logger.propagate = False
elif logger:
   self._logger = logger

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.

3 participants