Repository navigation
Add wrapper for timerfd_create, timerfd_settime, and timerfd_gettime to os module #108277
Description
Activity
- addedtype-featureA feature request or enhancementA feature request or enhancement
on Aug 22, 2023 - added 9 commits that reference this issue
on Aug 22, 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
osmodule, or if it's better to add platform-independent functions that hide the platform-specific implementation under the hood in thetimemodule.What do you think about it, @vstinner?
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.
3 remaining items
====================================================================== 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.99995https://github.com/python/cpython/actions/runs/6454439770/job/17519998313?pr=110539
- added a commit that references this issue
on Oct 11, 2023 AssertionError: 0.999 923 121 0000517 not greater than 0.99995Hum. 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".
Reacted by Malcolm SmithFor 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
placesarguments 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.If you propose a PR, I will review it.
- added 2 commits that reference this issue
on Apr 2, 2024
Feature 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
osmodule.Linked PRs