diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-08-23 07:01:10 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 07:01:10 (GMT) |
commit | 04e37850981bceaa31759c2673a945d3713ae7ae (patch) | |
tree | 0211f997e0e6f2ad39b2dafda30185c52c11bc61 | |
parent | dc6391705ed4934626f4119837190b994d90a7e1 (diff) | |
download | cpython-04e37850981bceaa31759c2673a945d3713ae7ae.zip cpython-04e37850981bceaa31759c2673a945d3713ae7ae.tar.gz cpython-04e37850981bceaa31759c2673a945d3713ae7ae.tar.bz2 |
[3.11] gh-96159: Fix significant performance degradation in logging.TimedRotat… (GH-96182) (GH-96196)
Co-authored-by: Duncan Grisby <duncan-github@grisby.org>
-rw-r--r-- | Lib/logging/handlers.py | 10 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2022-08-22-18-42-17.gh-issue-96159.3bFU39.rst | 1 |
2 files changed, 8 insertions, 3 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index 78b7560..2bcab65 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 diff --git a/Misc/NEWS.d/next/Library/2022-08-22-18-42-17.gh-issue-96159.3bFU39.rst b/Misc/NEWS.d/next/Library/2022-08-22-18-42-17.gh-issue-96159.3bFU39.rst new file mode 100644 index 0000000..f64469e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-08-22-18-42-17.gh-issue-96159.3bFU39.rst @@ -0,0 +1 @@ +Fix a performance regression in logging TimedRotatingFileHandler. Only check for special files when the rollover time has passed. |