[PATCH 1 of 2] test-static-http.t: get kill actually working

Adrian Buehlmann adrian at cadifra.com
Sun Dec 26 05:25:36 CST 2010


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1293361147 -3600
# Node ID 2e114ecae3fdd1268615633989fa99bb345aa7fd
# Parent  1aea66b71f4f915d482ea2be77e5322acf14db19
test-static-http.t: get kill actually working

- signal handlers take two arguments, not one
- add missing import sys

Before this patch, the

   $ kill $!

at the end of the test just caused a hidden traceback, sys.exit(0) was not
executed.

The swallowed traceback was:

  Traceback (most recent call last):
     File "dumb.py", line 10, in <module>
       run()
     File "dumb.py", line 7, in run
       httpd.serve_forever()
     File "/usr/lib/python2.6/SocketServer.py", line 224, in serve_forever
       r, w, e = select.select([self], [], [], poll_interval)
   TypeError: <lambda>() takes exactly 1 argument (2 given)

diff --git a/tests/test-static-http.t b/tests/test-static-http.t
--- a/tests/test-static-http.t
+++ b/tests/test-static-http.t
@@ -10,7 +10,7 @@ This server doesn't do range requests so
 one pull
 
   $ cat > dumb.py <<EOF
-  > import BaseHTTPServer, SimpleHTTPServer, os, signal
+  > import BaseHTTPServer, SimpleHTTPServer, os, signal, sys
   > 
   > def run(server_class=BaseHTTPServer.HTTPServer,
   >         handler_class=SimpleHTTPServer.SimpleHTTPRequestHandler):
@@ -18,7 +18,7 @@ one pull
   >     httpd = server_class(server_address, handler_class)
   >     httpd.serve_forever()
   > 
-  > signal.signal(signal.SIGTERM, lambda x: sys.exit(0))
+  > signal.signal(signal.SIGTERM, lambda x, y: sys.exit(0))
   > run()
   > EOF
   $ python dumb.py 2>/dev/null &


More information about the Mercurial-devel mailing list