Skip to content

PEP 475: handle EINTR in the time module, retry sleep() #67834

Closed

Description

@vstinner
BPO 23646
Nosy @pitrou, @vstinner
Files
  • sleep_eintr.patch
  • sleep.py
  • sleep_eintr-2.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2015-03-19.23:00:18.411>
    created_at = <Date 2015-03-12.15:37:42.547>
    labels = []
    title = 'PEP 475: handle EINTR in the time module, retry sleep()'
    updated_at = <Date 2015-03-20.02:06:25.652>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2015-03-20.02:06:25.652>
    actor = 'python-dev'
    assignee = 'none'
    closed = True
    closed_date = <Date 2015-03-19.23:00:18.411>
    closer = 'vstinner'
    components = []
    creation = <Date 2015-03-12.15:37:42.547>
    creator = 'vstinner'
    dependencies = []
    files = ['38454', '38455', '38457']
    hgrepos = []
    issue_num = 23646
    keywords = ['patch']
    message_count = 11.0
    messages = ['237948', '237949', '237952', '237953', '237959', '237983', '238269', '238270', '238557', '238594', '238599']
    nosy_count = 4.0
    nosy_names = ['pitrou', 'vstinner', 'neologix', 'python-dev']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue23646'
    versions = ['Python 3.5']

    Activity

    1. vstinner commented on Mar 12, 2015

      @vstinner
      MemberAuthor

      Attached patch changes time.sleep() to retry select() when select() is interrupted by a signal or retry WaitForSingleObjectEx() when the signal SIGINT is received on Windows.

      The patch drops support for EMX, sorry! I didn't know EMX, I had to Google it: "EMX is a free 32-bit DOS extender which adds some properties of Unix to MS-compatible DOS and IBM's OS/2 operating systems." (OS/2 support was dropped in Python 3.4 by the PEP-11.)

      The patch also drops support for Watcom C compiler. I guess that it's also something specific to MS-DOS or very old (and unsupported) Windows versions.

      select.select() is available on all platforms according to the doc, so I don't understand why we would not use it on all platforms for time.sleep() in 2015!
      https://docs.python.org/dev/library/select.html#select.select

    2. vstinner commented on Mar 12, 2015

      @vstinner
      MemberAuthor

      The patch includes a unit test for POSIX.

      For Windows, you can test manually using the attached sleep.py program: press CTRL+c to send SIGINT signals.

    3. vstinner commented on Mar 12, 2015

      @vstinner
      MemberAuthor

      Oh, test_signal fails with the patch because time.sleep() is not interrupted by a signal. New patch.

      I also reverted #ifdef order in floatsleep() to have a patch easier to review.

    4. vstinner commented on Mar 12, 2015

      @vstinner
      MemberAuthor

      Note: test_signal will have to be modified again when select will also retry on EINTR :-) See issue bpo-23485. For example, test_signal.test_wakeup_fd_early() can register a signal handler which raises an exception and catch InterruptedError.

    5. neologix commented on Mar 12, 2015

      neologixmannequin
      Mannequin

      As for the change to select/poll/etc, IIRC Guido was opposed to it,
      that's why I didn't update them.

    6. vstinner commented on Mar 12, 2015

      @vstinner
      MemberAuthor

      Le jeudi 12 mars 2015, Charles-François Natali <report@bugs.python.org> a
      écrit :

      As for the change to select/poll/etc, IIRC Guido was opposed to it,
      that's why I didn't update them.

      Wait what? can you elaborate? I'm not aware of that.

    7. python-dev commented on Mar 17, 2015

      python-devmannequin
      Mannequin

      New changeset 4accc35cbfcf by Victor Stinner in branch 'default':
      Revert changeset d927047b1d8eb87738676980a24930d053ba2150
      https://hg.python.org/cpython/rev/4accc35cbfcf

    8. vstinner commented on Mar 17, 2015

      @vstinner
      MemberAuthor

      I commited sleep_eintr.patch by mistake. After this change, test_socket started to fail on Windows. I don't understand why.

      http://buildbot.python.org/all/builders/AMD64%20Windows7%20SP1%203.x/builds/5836/steps/test/logs/stdio

      ======================================================================
      ERROR: testClose (test.test_socket.TCPCloserTest)
      ----------------------------------------------------------------------

      Traceback (most recent call last):
        File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_socket.py", line 3723, in testClose
          read, write, err = select.select([sd], [], [], 1.0)
      TypeError: argument must be an int, or have a fileno() method.

      ======================================================================
      FAIL: testRecv (test.test_socket.NonBlockingTCPTests)
      ----------------------------------------------------------------------

      Traceback (most recent call last):
        File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_socket.py", line 3883, in testRecv
          self.fail("Error trying to do non-blocking recv.")
      AssertionError: Error trying to do non-blocking recv.
    9. python-dev commented on Mar 19, 2015

      python-devmannequin
      Mannequin

      New changeset b1abd06465fc by Victor Stinner in branch 'default':
      Issue bpo-23646: If time.sleep() is interrupted by a signal, the sleep is now
      https://hg.python.org/cpython/rev/b1abd06465fc

    10. python-dev commented on Mar 20, 2015

      python-devmannequin
      Mannequin

      New changeset 9882cc2efd36 by Victor Stinner in branch 'default':
      Issue bpo-23646: Enhance precision of time.sleep() and socket timeout when
      https://hg.python.org/cpython/rev/9882cc2efd36

    11. python-dev commented on Mar 20, 2015

      python-devmannequin
      Mannequin

      New changeset 1291649f38df by Victor Stinner in branch 'default':
      Issue bpo-23646: Fix test_threading on Windows
      https://hg.python.org/cpython/rev/1291649f38df

    12. transferred this issue fromon Apr 10, 2022
    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

      No labels
      No labels

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions