You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add wrapper for timerfd_create, timerfd_settime, and timerfd_gettime to os module #108277
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.
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.
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".
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.
Activity
pythongh-108277: Add wrapper for timerfd_create, timerfd_settime, and…
pythongh-108277: Add wrapper for timerfd_create, timerfd_settime, and…
pythongh-108277: Add wrapper functions for timerfd_create, timerfd_se…
pythongh-108277: Add wrapper functions for timerfd_create, timerfd_se…
pythongh-108277: Add wrapper functions for timerfd_create, timerfd_se…
pythongh-108277: Add wrapper functions for timerfd_create, timerfd_se…
pythongh-108277: Add wrapper functions for timerfd_create, timerfd_se…
pythongh-108277: Add wrapper functions for timerfd_create, timerfd_se…
pythongh-108277: Add wrapper functions for timerfd_create, timerfd_se…
serhiy-storchaka commentedon 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
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?
pythongh-108277: Add wrapper functions for timerfd_create, timerfd_se…
vstinner commentedon 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?
Which platforms support these APIs?
Only Linux support these APIs according to the doc.
gh-108277: Add os.timerfd_create() function (#108382)
pythongh-108277: Fix test_os TimerfdTests
3 remaining items
serhiy-storchaka commentedon Oct 9, 2023
https://github.com/python/cpython/actions/runs/6454439770/job/17519998313?pr=110539
pythongh-108277: test_os tolerates 1 ms diff for timerfd
vstinner commentedon 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".
gh-108277: test_os tolerates 1 ms diff for timerfd (#110661)
mhsmith commentedon 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
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.vstinner commentedon Mar 21, 2024
If you propose a PR, I will review it.
pythongh-108277: Make test_os tolerate 10 ms diff for timerfd
gh-108277: Make test_os tolerate 10 ms diff for timerfd on Android em…
Squashed commit of the following:
Squashed commit of the following:
pythongh-108277: Make test_os tolerate 10 ms diff for timerfd on Andr…
pythongh-108277: Add os.timerfd_create() function (python#108382)
pythongh-108277: Fix test_os TimerfdTests (python#110515)
pythongh-108277: test_os tolerates 1 ms diff for timerfd (python#110661)