FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-84649: Use statx() in TimedRotatingFileHandler if available by serhiy-storchaka · Pull Request #150968 · python/cpython · GitHub

Repository navigation

gh-84649: Use statx() in TimedRotatingFileHandler if available - #150968

Merged
serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:TimedRotatingFileHandler-statx
Jun 6, 2026
Merged

serhiy-storchaka merged 3 commits into
python:mainfrom
serhiy-storchaka:TimedRotatingFileHandler-statx

Conversation

serhiy-storchaka commented Jun 5, 2026 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

This allows to support rotation based on the file birth time on Linux.

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@vstinner, could you please look at this? Do I use statx() like it is supposed to be used?

Comment thread Lib/test/test_logging.py Outdated
@unittest.skipUnless(hasattr(os.stat_result, 'st_birthtime') or
support.has_st_birthtime or hasattr(os, 'statx'),
"st_birthtime and statx() not available or supported by Python on this OS")
# @support.requires_resource('walltime')

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is temporary, to run tests once on CI.

This allows to support rotation based on the file birth time on Linux.
serhiy-storchaka force-pushed the TimedRotatingFileHandler-statx branch from e584956 to e1c910e Compare June 5, 2026 13:11

vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM. The code using os.statx() is correct. Don't forget to uncomment # @support.requires_resource('walltime').

Comment thread Lib/logging/handlers.py
# Use stx_btime whenever it is available or use stx_ctime
# instead otherwise
creation_time = statx_result.stx_btime
if creation_time is None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Right, stx_btime can be None. For example, on a tmpfs filesystem, on Linux 5.17 and older: #83714 (comment).

read-the-docs-community Bot commented Jun 5, 2026 •
edited
Loading

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33010529 | 📁 Comparing 643c819 against main (9f225e2)

  🔍 Preview build  

3 files changed
± library/logging.handlers.html
± whatsnew/3.16.html
± whatsnew/changelog.html

serhiy-storchaka merged commit b18b6a4 into python:main Jun 6, 2026
52 checks passed
serhiy-storchaka deleted the TimedRotatingFileHandler-statx branch July 1, 2026 16:47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL