Skip to content

Ensure before_sleep_log message isn't multiline#512

Open
sebastian-correa wants to merge 1 commit into
jd:mainfrom
sebastian-correa:patch-1
Open

Ensure before_sleep_log message isn't multiline#512
sebastian-correa wants to merge 1 commit into
jd:mainfrom
sebastian-correa:patch-1

Conversation

@sebastian-correa

Copy link
Copy Markdown

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

@mergify

mergify Bot commented Jan 31, 2025

Copy link
Copy Markdown
Contributor

⚠️ 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

jd commented Feb 3, 2025

Copy link
Copy Markdown
Owner

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
Copy Markdown
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

jd commented Feb 6, 2025

Copy link
Copy Markdown
Owner

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