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

Ensure before_sleep_log message isn't multiline #512

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

Conversation

sebastian-correa
Copy link

Some exceptions add extra \n characters to their message, causing the last . in the log to be a new line.

Copy link
Contributor

mergify bot commented Jan 31, 2025

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

Some exceptions add extra `\n` characters to their message, causing the last . in the log to be a new line.
@jd
Copy link
Owner

jd commented Feb 3, 2025

I'm failing to see how this is a problem in tenacity itself and not in the so called exception though

@sebastian-correa
Copy link
Author

@jd the PR's title might be a bit overreaching, since it won't solve actual multiline string representations (i.e., if the exception has \n "in between"). However, since the tenacity log adds a. `` at the end, I think the expectation (when implemented) was that it would come immediately after the exception string, which might not be the case if it ends with \n.

I do agree that the actual problem is more probably in the exception, but tenacity logs end up split across multiple lines. I thought about implementing my own before_sleep_log, but since it uses a private function, I desisted.

@jd
Copy link
Owner

jd commented Feb 6, 2025

Right; I'd rather change the log line to not have a final . but using something like {verb}: {e}

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.

2 participants