diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-08-23 07:00:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 07:00:40 (GMT) |
commit | 9c34d644edec7e5d4da78317ad2bbceb246aa039 (patch) | |
tree | 9387d0324cd013776ac936703b6dfffe1deff81a /Lib/logging | |
parent | e9ede9d2a0376961933c03245199a8f348a9880c (diff) | |
download | cpython-9c34d644edec7e5d4da78317ad2bbceb246aa039.zip cpython-9c34d644edec7e5d4da78317ad2bbceb246aa039.tar.gz cpython-9c34d644edec7e5d4da78317ad2bbceb246aa039.tar.bz2 |
[3.10] gh-96159: Fix significant performance degradation in logging.TimedRotat… (GH-96182) (GH-96195)
Co-authored-by: Duncan Grisby <duncan-github@grisby.org>
Diffstat (limited to 'Lib/logging')
-rw-r--r-- | Lib/logging/handlers.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py index b2d1f27..32c0420 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 |