[issue12363] test_signal.test_without_siginterrupt() sporadic failures on FreeBSD 6.4

Charles-François Natali report at bugs.python.org
Tue Jun 21 23:05:57 CEST 2011


Charles-François Natali <neologix at free.fr> added the comment:

Duh, don't know what I was thinking: the syscall is not restarted
(even though ERESTARTSYS is displayed by strace): the real problem is
that the 3s timeout to communicate is not enough, because spawning a
new interpreter can take a long time (Antoine created an issue some
time ago about the high number of syscalls per import). If it takes
more than 1s, the test will fail.
Also, I guess it's worst on FreeBSD because subprocess.Popen uses
close_fds=True by default, and FreeBSD has a huge default
_SC_OPEN_MAX.
I've attached a patch passing close_fds=False to spawn_python, and
running the test only once, because otherwise this would require a
timeout quite large.

----------
Added file: http://bugs.python.org/file22420/test_siginterrupt.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12363>
_______________________________________
-------------- next part --------------
diff -r 10ecf8576eb2 Lib/test/test_signal.py
--- a/Lib/test/test_signal.py	Tue Jun 21 17:24:21 2011 +0200
+++ b/Lib/test/test_signal.py	Tue Jun 21 23:03:18 2011 +0200
@@ -337,21 +337,19 @@
             if interrupt is not None:
                 signal.siginterrupt(signal.SIGALRM, interrupt)
 
-            # run the test twice
-            for loop in range(2):
-                # send a SIGALRM in a second (during the read)
-                signal.alarm(1)
-                try:
-                    # blocking call: read from a pipe without data
-                    os.read(r, 1)
-                except OSError as err:
-                    if err.errno != errno.EINTR:
-                        raise
-                else:
-                    sys.exit(2)
+            # send a SIGALRM in a second (during the read)
+            signal.alarm(1)
+            try:
+                # blocking call: read from a pipe without data
+                os.read(r, 1)
+            except OSError as err:
+                if err.errno != errno.EINTR:
+                    raise
+            else:
+                sys.exit(2)
             sys.exit(3)
         """ % (interrupt,)
-        with spawn_python('-c', code) as process:
+        with spawn_python('-c', code, close_fds=False) as process:
             try:
                 stdout, stderr = process.communicate(timeout=3.0)
             except subprocess.TimeoutExpired:


More information about the Python-bugs-list mailing list