Skip to content

Add wrapper for timerfd_create, timerfd_settime, and timerfd_gettime to os module #108277

Description

@m-tmatma

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 os module.

Linked PRs

Activity

  1. added 9 commits that reference this issue on Aug 22, 2023
  2. serhiy-storchaka commented on Aug 28, 2023

    @serhiy-storchaka
    Member

    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?

  3. added a commit that references this issue on Aug 28, 2023
  4. vstinner commented on Aug 28, 2023

    @vstinner
    Member

    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.

  5. added 2 commits that reference this issue on Oct 7, 2023
  6. 3 remaining items

  7. serhiy-storchaka commented on Oct 9, 2023

    @serhiy-storchaka
    Member
    ======================================================================
    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

  8. added a commit that references this issue on Oct 11, 2023
  9. vstinner commented on Oct 11, 2023

    @vstinner
    Member

    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".

  10. added a commit that references this issue on Oct 11, 2023
  11. mhsmith commented on Mar 20, 2024

    @mhsmith
    Member

    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.

  12. vstinner commented on Mar 21, 2024

    @vstinner
    Member

    If you propose a PR, I will review it.

  13. added 2 commits that reference this issue on Mar 25, 2024
  14. added a commit that references this issue on Apr 17, 2024
  15. added 3 commits that reference this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions