summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorDuncan Grisby <duncan-github@grisby.org>2022-08-23 06:28:43 (GMT)
committerGitHub <noreply@github.com>2022-08-23 06:28:43 (GMT)
commit1499d73b3e02878850c007fa7298bb62f6c5a9a1 (patch)
tree3f218a46b6448e6889bcf8fc784de8d02b2b28c5 /Lib/logging
parent129998bd7b133defa37c7529bfad9052c0022b5c (diff)
downloadcpython-1499d73b3e02878850c007fa7298bb62f6c5a9a1.zip
cpython-1499d73b3e02878850c007fa7298bb62f6c5a9a1.tar.gz
cpython-1499d73b3e02878850c007fa7298bb62f6c5a9a1.tar.bz2
gh-96159: Fix significant performance degradation in logging.TimedRotat… (GH-96182)
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/handlers.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 1c8226c..3f97862 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -348,11 +348,15 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
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