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
Comments
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! |
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. |
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. |
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. |
As for the change to select/poll/etc, IIRC Guido was opposed to it, |
Le jeudi 12 mars 2015, Charles-François Natali <report@bugs.python.org> a
Wait what? can you elaborate? I'm not aware of that. |
New changeset 4accc35cbfcf by Victor Stinner in branch 'default': |
I commited sleep_eintr.patch by mistake. After this change, test_socket started to fail on Windows. I don't understand why. ====================================================================== 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 testRecv
self.fail("Error trying to do non-blocking recv.")
AssertionError: Error trying to do non-blocking recv. |
New changeset b1abd06465fc by Victor Stinner in branch 'default': |
New changeset 9882cc2efd36 by Victor Stinner in branch 'default': |
New changeset 1291649f38df by Victor Stinner in branch 'default': |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: