Skip to content

[3.10] gh-96159: Fix significant performance degradation in logging.TimedRotat… (GH-96182) (GH-96195) #96195

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

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Lib/logging/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,15 @@ def shouldRollover(self, record):
record is not used, as we are just comparing times, but it is needed so
the method signatures are the same
"""
# See bpo-45401: Never rollover anything other than regular files
if os.path.exists(self.baseFilename) and not os.path.isfile(self.baseFilename):
return False
t = int(time.time())
if t >= self.rolloverAt:
# See #89564: Never rollover anything other than regular files
if os.path.exists(self.baseFilename) and not os.path.isfile(self.baseFilename):
# The file is not a regular file, so do not rollover, but do
# set the next rollover time to avoid repeated checks.
self.rolloverAt = self.computeRollover(t)
return False

return True
return False

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix a performance regression in logging TimedRotatingFileHandler. Only check for special files when the rollover time has passed.