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

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

Closed
vstinner opened this issue Mar 12, 2015 · 11 comments
Closed

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

vstinner opened this issue Mar 12, 2015 · 11 comments

Comments

@vstinner
Copy link
Member

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']

    @vstinner
    Copy link
    Member Author

    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

    @vstinner
    Copy link
    Member Author

    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.

    @vstinner
    Copy link
    Member Author

    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.

    @vstinner
    Copy link
    Member Author

    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.

    @neologix
    Copy link
    Mannequin

    neologix mannequin commented Mar 12, 2015

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

    @vstinner
    Copy link
    Member Author

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 17, 2015

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

    @vstinner
    Copy link
    Member Author

    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.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 19, 2015

    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

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 20, 2015

    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

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 20, 2015

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

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    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

    No branches or pull requests

    1 participant