mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-96159: Fix significant performance degradation in logging.TimedRotat… (GH-96182)
This commit is contained in:
parent
129998bd7b
commit
1499d73b3e
2 changed files with 8 additions and 3 deletions
|
|
@ -348,11 +348,15 @@ def shouldRollover(self, record):
|
||||||
record is not used, as we are just comparing times, but it is needed so
|
record is not used, as we are just comparing times, but it is needed so
|
||||||
the method signatures are the same
|
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())
|
t = int(time.time())
|
||||||
if t >= self.rolloverAt:
|
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 True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Fix a performance regression in logging TimedRotatingFileHandler. Only check for special files when the rollover time has passed.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue