GeezerVison is showing github.com — Add wrapper for timerfd_create, timerfd_settime, and timerfd_gettime to `os` module · Issue #108277 · python/cpython
Add wrapper for timerfd_create, timerfd_settime, and timerfd_gettime to os module #108277DescriptionFeature or enhancement
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
Proposal:
eventfd is implemented at #20930 (#85173).
But timerfd is not implemented yet.
timerfd_create, timerfd_settime, and timerfd_gettime are Linux syscalls that create and operate on a timer that delivers timer expiration notifications via a file descriptor.
See https://man7.org/linux/man-pages/man2/timerfd_create.2.html
I propse to add those wrapper functions to os module.
Linked PRs
Activityserhiy-storchaka commented on Aug 28, 2023 Should not we first add POSIX conforming timer_create(), timer_settime(), timer_gettime(), timer_getoverrun()?
Also, I'm not sure if we should add these low-level platform-specific functions in the os module, or if it's better to add platform-independent functions that hide the platform-specific implementation under the hood in the time module.
What do you think about it, @vstinner? vstinner commented on Aug 28, 2023 IMO it's a good thin to expose the API in the os, thin wrapper to the C functions. Then anyone is free to write their own high-level API on top of it.
Who is going to use these APIs? For which use case?
Should not we first add POSIX conforming timer_create(), timer_settime(), timer_gettime(), timer_getoverrun()?
Which platforms support these APIs?
timerfd_create, timerfd_settime, and timerfd_gettime
Only Linux support these APIs according to the doc. serhiy-storchaka commented on Oct 9, 2023 ======================================================================
FAIL: test_timerfd_TFD_TIMER_ABSTIME (test.test_os.TimerfdTests.test_timerfd_TFD_TIMER_ABSTIME)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/work/cpython/cpython/Lib/test/test_os.py", line 4066, in test_timerfd_TFD_TIMER_ABSTIME
self.assertGreater(t, offset - self.CLOCK_RES)
AssertionError: 0.9999231210000517 not greater than 0.99995
https://github.com/python/cpython/actions/runs/6454439770/job/17519998313?pr=110539 vstinner commented on Oct 11, 2023 AssertionError: 0.999 923 121 0000517 not greater than 0.99995
Hum. When @m-tmatma wrote the test, the test expects >= 1.0. I modified the test to tolerate 50 us difference. I don't want to play this whack-a-mole game for too long, I wrote PR #110661 to tolerate 1 ms difference. I don't know which clocks are involved, but I don't think that Python should test the operating system itself, it should just test that it's thin wrapper to OS functions "seem to work". mhsmith commented on Mar 20, 2024 For future reference: I have two laptops I use for Android development, and to pass these tests reliably on the slower one, I had to increase the margin to 2 ms, and reduce the places arguments from 3 to 2. But I probably won't be creating a PR for this, because this laptop is really too slow to be a modern Android development machine, so I doubt it will affect anyone else. vstinner commented on Mar 21, 2024 If you propose a PR, I will review it. added 2 commits that reference this issue on Mar 25, 2024gh-108277: Make test_os tolerate 10 ms diff for timerfd on Android em…
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|