Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-108277: Add wrapper for timerfd_create, timerfd_settime, and timerfd_gettime to os module #108382

Merged
merged 170 commits into from Oct 7, 2023

Conversation

m-tmatma
Copy link
Contributor

@m-tmatma m-tmatma commented Aug 23, 2023

Add wrapper for timerfd system calls.

Note: local test

python3 Tools/clinic/clinic.py -f Modules/posixmodule.c &&  \
autoconf -i && \
./configure && \
make regen-configure && \
make -j4 regen-all   && \
make regen-stdlib-module-names &&  \
make test TESTOPTS="-v test_os" && \
make -C Doc venv && make -C Doc html

📚 Documentation preview 📚: https://cpython-previews--108382.org.readthedocs.build/

@cpython-cla-bot

This comment was marked as resolved.

@bedevere-bot

This comment was marked as outdated.

@bedevere-bot

This comment was marked as outdated.

@bedevere-bot

This comment was marked as outdated.

@m-tmatma m-tmatma force-pushed the feature/os.timerfd_xxx branch 5 times, most recently from 61a9908 to ebd989f Compare August 26, 2023 09:34
Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

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

In general LGTM, but we must first discuss what exactly we want to get.

Doc/library/os.rst Outdated Show resolved Hide resolved
Modules/posixmodule.c Show resolved Hide resolved
@serhiy-storchaka
Copy link
Member

Please add also an entry in the What's New file.

@erlend-aasland
Copy link
Contributor

Just a heads-up, @m-tmatma: please don't force-push; instead, git merge --no-ff main. It makes for a better review experience, since both CI runs and comments can be tied to specific commits.

@m-tmatma
Copy link
Contributor Author

@erlend-aasland

Just a heads-up, @m-tmatma: please don't force-push; instead, git merge --no-ff main. It makes for a better review experience, since both CI runs and comments can be tied to specific commits.

Sorry, I thought force-push is a manner to contribute.

@m-tmatma
Copy link
Contributor Author

@serhiy-storchaka

Please add also an entry in the What's New file.

Added.

@m-tmatma
Copy link
Contributor Author

m-tmatma commented Oct 5, 2023

@serhiy-storchaka

Could them be moved in the "How To" file or in separate Python files?

I'll check how to move in "How To" file.

Moved examples to HOWTO.

Python/pytime.c Outdated Show resolved Hide resolved
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for all updates!

IMO using _PyTime_t API and passing the rounding method from the time module is the right way to handle rounding.

@vstinner vstinner merged commit de2a403 into python:main Oct 7, 2023
23 checks passed
@vstinner
Copy link
Member

vstinner commented Oct 7, 2023

I merged your PR, thanks @m-tmatma for your great work!

Some remarks:

  • The PR got reviewed by multiple core devs.
  • IMO os.rst doc should have a link to the HOWTO: please propose a follow-up PR for that.
  • I like the API with only 1 positional-only parameter, and then keyword-only arguments: we need more APIs like that :-)
  • I'm scared by the size of the change, the size of the API, but I'm reassured by the length of the documentation and the length of the tests. Thanks for writing all of that!
  • I also merged this PR because it has too many comments, too many commits. It became really hard to track it :-) I merge it to have a "starting point". Later, we can obviously enhance doc/implementation/tests/whatever.

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 RHEL7 3.x has failed when building commit de2a403.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/15/builds/5889) and take a look at the build logs.
  4. Check if the failure is related to this commit (de2a403) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/15/builds/5889

Failed tests:

  • test_os

Failed subtests:

  • test_timerfd_negative - test.test_os.TimerfdTests.test_timerfd_negative

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/buildbot/buildarea/3.x.cstratak-RHEL7-x86_64/build/Lib/test/test_os.py", line 3987, in test_timerfd_negative
    for flags in (0, os.TFD_TIMER_ABSTIME, os.TFD_TIMER_ABSTIME|os.TFD_TIMER_CANCEL_ON_SET):
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'os' has no attribute 'TFD_TIMER_CANCEL_ON_SET'

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x RHEL7 3.x has failed when building commit de2a403.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/179/builds/5673) and take a look at the build logs.
  4. Check if the failure is related to this commit (de2a403) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/179/builds/5673

Failed tests:

  • test_os

Failed subtests:

  • test_timerfd_negative - test.test_os.TimerfdTests.test_timerfd_negative

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z/build/Lib/test/test_os.py", line 3987, in test_timerfd_negative
    for flags in (0, os.TFD_TIMER_ABSTIME, os.TFD_TIMER_ABSTIME|os.TFD_TIMER_CANCEL_ON_SET):
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'os' has no attribute 'TFD_TIMER_CANCEL_ON_SET'

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x RHEL7 LTO + PGO 3.x has failed when building commit de2a403.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/244/builds/5632) and take a look at the build logs.
  4. Check if the failure is related to this commit (de2a403) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/244/builds/5632

Failed tests:

  • test_os

Failed subtests:

  • test_timerfd_negative - test.test_os.TimerfdTests.test_timerfd_negative

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.lto-pgo/build/Lib/test/test_os.py", line 3987, in test_timerfd_negative
    for flags in (0, os.TFD_TIMER_ABSTIME, os.TFD_TIMER_ABSTIME|os.TFD_TIMER_CANCEL_ON_SET):
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'os' has no attribute 'TFD_TIMER_CANCEL_ON_SET'

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x RHEL7 LTO 3.x has failed when building commit de2a403.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/402/builds/5581) and take a look at the build logs.
  4. Check if the failure is related to this commit (de2a403) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/402/builds/5581

Failed tests:

  • test_os

Failed subtests:

  • test_timerfd_negative - test.test_os.TimerfdTests.test_timerfd_negative

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-rhel-z.lto/build/Lib/test/test_os.py", line 3987, in test_timerfd_negative
    for flags in (0, os.TFD_TIMER_ABSTIME, os.TFD_TIMER_ABSTIME|os.TFD_TIMER_CANCEL_ON_SET):
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'os' has no attribute 'TFD_TIMER_CANCEL_ON_SET'

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot AMD64 Ubuntu Shared 3.x has failed when building commit de2a403.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/506/builds/6080) and take a look at the build logs.
  4. Check if the failure is related to this commit (de2a403) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/506/builds/6080

Failed tests:

  • test_os

Failed subtests:

  • test_timerfd_ns_TFD_TIMER_ABSTIME - test.test_os.TimerfdTests.test_timerfd_ns_TFD_TIMER_ABSTIME

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_os.py", line 4211, in test_timerfd_ns_TFD_TIMER_ABSTIME
    self.assertGreater(t, offset_ns)
AssertionError: 999978637 not greater than 1000000000

@bedevere-bot
Copy link

⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️

Hi! The buildbot s390x Fedora Clang 3.x has failed when building commit de2a403.

What do you need to do:

  1. Don't panic.
  2. Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
  3. Go to the page of the buildbot that failed (https://buildbot.python.org/all/#builders/3/builds/4767) and take a look at the build logs.
  4. Check if the failure is related to this commit (de2a403) or if it is a false positive.
  5. If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.

You can take a look at the buildbot page here:

https://buildbot.python.org/all/#builders/3/builds/4767

Failed tests:

  • test_os

Failed subtests:

  • test_timerfd_ns_TFD_TIMER_ABSTIME - test.test_os.TimerfdTests.test_timerfd_ns_TFD_TIMER_ABSTIME
  • test_timerfd_TFD_TIMER_ABSTIME - test.test_os.TimerfdTests.test_timerfd_TFD_TIMER_ABSTIME

Summary of the results of the build (if available):

==

Click to see traceback logs
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/test/test_os.py", line 4211, in test_timerfd_ns_TFD_TIMER_ABSTIME
    self.assertGreater(t, offset_ns)
AssertionError: 999998128 not greater than 1000000000


Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/test/test_os.py", line 4058, in test_timerfd_TFD_TIMER_ABSTIME
    self.assertGreater(t, offset)
AssertionError: 0.9999921415001154 not greater than 1

@m-tmatma
Copy link
Contributor Author

m-tmatma commented Oct 7, 2023

@vstinner
Thank you for merging.

@m-tmatma m-tmatma deleted the feature/os.timerfd_xxx branch October 7, 2023 20:55
@vstinner
Copy link
Member

vstinner commented Oct 7, 2023

@m-tmatma: Now you can enjoy the great pleasure of having to fix test failures :-) Look at previous comments from buildbots.

======================================================================
FAIL: test_timerfd_TFD_TIMER_ABSTIME (test.test_os.TimerfdTests.test_timerfd_TFD_TIMER_ABSTIME)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/test/test_os.py", line 4058, in test_timerfd_TFD_TIMER_ABSTIME
    self.assertGreater(t, offset)
AssertionError: 0.9999921415001154 not greater than 1

======================================================================
FAIL: test_timerfd_ns_TFD_TIMER_ABSTIME (test.test_os.TimerfdTests.test_timerfd_ns_TFD_TIMER_ABSTIME)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-fedora-z.clang/build/Lib/test/test_os.py", line 4211, in test_timerfd_ns_TFD_TIMER_ABSTIME
    self.assertGreater(t, offset_ns)
AssertionError: 999998128 not greater than 1000000000

@m-tmatma
Copy link
Contributor Author

m-tmatma commented Oct 7, 2023

@vstinner
sorry, but I'm going to travel. so it takes a week to start fixing.

@m-tmatma
Copy link
Contributor Author

m-tmatma commented Oct 7, 2023

@vstinner
I didn't notice these failures until the PR
was merged.

Some tests are only run only on main branch?

There were some difficulties when I had developed this feature because actions was not enabled on feature branches.

I think all actions jobs should be run on feature branches or at least PRs to prevent the case on the PR.

@vstinner
Copy link
Member

vstinner commented Oct 8, 2023

@vstinner: I didn't notice these failures until the PR was merged.

It's because buildbots are not run before a PR is actually merged, until someone asks explicitly to run buildbots on a PR, which wasn't done.

It's ok. I may have a look at these failures and try to fix them.

@vstinner
Copy link
Member

vstinner commented Oct 8, 2023

On AMD64 RHEL7 3.x, test_timerfd_negative() fails because os.TFD_TIMER_CANCEL_ON_SET doesn't exist. test.pythoninfo:

os.uname: posix.uname_result(sysname='Linux', nodename='python-builder-rhel7.osci.io', release='3.10.0-1160.95.1.el7.x86_64', version='#1 SMP Fri Jun 23 08:44:55 EDT 2023', machine='x86_64')
platform.architecture: 64bit ELF
platform.freedesktop_os_release[ID]: rhel
platform.freedesktop_os_release[NAME]: Red Hat Enterprise Linux Server
platform.freedesktop_os_release[VARIANT_ID]: server
platform.freedesktop_os_release[VERSION]: 7.9 (Maipo)
platform.freedesktop_os_release[VERSION_ID]: 7.9
platform.libc_ver: glibc 2.17
platform.platform: Linux-3.10.0-1160.95.1.el7.x86_64-x86_64-with-glibc2.17

@vstinner
Copy link
Member

vstinner commented Oct 8, 2023

AMD64 Ubuntu Shared 3.x: https://buildbot.python.org/all/#/builders/506/builds/6080

FAIL: test_timerfd_ns_TFD_TIMER_ABSTIME (test.test_os.TimerfdTests.test_timerfd_ns_TFD_TIMER_ABSTIME)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_os.py", line 4211, in test_timerfd_ns_TFD_TIMER_ABSTIME
    self.assertGreater(t, offset_ns)
AssertionError: 999978637 not greater than 1000000000

@vstinner
Copy link
Member

vstinner commented Oct 8, 2023

I wrote PR #110515 to fix tests.

@m-tmatma
Copy link
Contributor Author

m-tmatma commented Oct 8, 2023

@vstinner
Thank you for the PR.

@vstinner
Copy link
Member

vstinner commented Oct 8, 2023

It seems like buildbots are happy, good. Refleaks will run with the fix this night.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants