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
PEP 475: handle EINTR in the time module, retry sleep() #67834
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=Noneclosed_at=<Date2015-03-19.23:00:18.411>created_at=<Date2015-03-12.15:37:42.547>labels= []
title='PEP 475: handle EINTR in the time module, retry sleep()'updated_at=<Date2015-03-20.02:06:25.652>user='https://github.com/vstinner'
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.
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 commented on Mar 12, 2015
neologixmannequin
Mannequin
More actions
As for the change to select/poll/etc, IIRC Guido was opposed to it,
that's why I didn't update them.
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.
Traceback (most recent call last):
File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_socket.py", line 3883, in testRecvself.fail("Error trying to do non-blocking recv.")
AssertionError: Error trying to do non-blocking recv.
Activity
vstinner commentedon Mar 12, 2015
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 commentedon Mar 12, 2015
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 commentedon Mar 12, 2015
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 commentedon Mar 12, 2015
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 commentedon 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 commentedon Mar 12, 2015
Le jeudi 12 mars 2015, Charles-François Natali <report@bugs.python.org> a
écrit :
Wait what? can you elaborate? I'm not aware of that.
python-dev commentedon Mar 17, 2015
New changeset 4accc35cbfcf by Victor Stinner in branch 'default':
Revert changeset d927047b1d8eb87738676980a24930d053ba2150
https://hg.python.org/cpython/rev/4accc35cbfcf
vstinner commentedon Mar 17, 2015
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)
----------------------------------------------------------------------
======================================================================
FAIL: testRecv (test.test_socket.NonBlockingTCPTests)
----------------------------------------------------------------------
python-dev commentedon 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 commentedon 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 commentedon 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