diff options
author | Jeffrey Yasskin <jyasskin@gmail.com> | 2008-03-05 06:19:56 (GMT) |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@gmail.com> | 2008-03-05 06:19:56 (GMT) |
commit | f28896d0bb8a1550dae5b025d0397d38b143eb65 (patch) | |
tree | 55b4cc745957ab22b3df8f8369249dcf28023b13 | |
parent | 89cb9b799b63dd1c1421f6dec3c7f4de4d7cc77e (diff) | |
download | cpython-f28896d0bb8a1550dae5b025d0397d38b143eb65.zip cpython-f28896d0bb8a1550dae5b025d0397d38b143eb65.tar.gz cpython-f28896d0bb8a1550dae5b025d0397d38b143eb65.tar.bz2 |
Fix test_socketserver on Windows after r61099 added several signal.alarm()
calls (which don't exist on non-Unix platforms).
Thanks to Trent Nelson for the report and patch.
-rw-r--r-- | Lib/test/test_socketserver.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py index 98a4c1f..92e5d04 100644 --- a/Lib/test/test_socketserver.py +++ b/Lib/test/test_socketserver.py @@ -28,6 +28,10 @@ HOST = "localhost" HAVE_UNIX_SOCKETS = hasattr(socket, "AF_UNIX") HAVE_FORKING = hasattr(os, "fork") and os.name != "os2" +def signal_alarm(n): + """Call signal.alarm when it exists (i.e. not on Windows).""" + if hasattr(signal, 'alarm'): + signal.alarm(n) def receive(sock, n, timeout=20): r, w, x = select.select([sock], [], [], timeout) @@ -99,7 +103,7 @@ class SocketServerTest(unittest.TestCase): """Test all socket servers.""" def setUp(self): - signal.alarm(20) # Kill deadlocks after 20 seconds. + signal_alarm(20) # Kill deadlocks after 20 seconds. self.port_seed = 0 self.test_files = [] @@ -112,7 +116,7 @@ class SocketServerTest(unittest.TestCase): except os.error: pass self.test_files[:] = [] - signal.alarm(0) # Didn't deadlock. + signal_alarm(0) # Didn't deadlock. def pickaddr(self, proto): if proto == socket.AF_INET: @@ -267,4 +271,4 @@ def test_main(): if __name__ == "__main__": test_main() - signal.alarm(3) # Shutdown shouldn't take more than 3 seconds. + signal_alarm(3) # Shutdown shouldn't take more than 3 seconds. |