summaryrefslogtreecommitdiff
path: root/indra/llmessage/tests/test_llsdmessage_peer.py
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2016-12-07 09:30:49 -0500
committerNat Goodspeed <nat@lindenlab.com>2016-12-07 09:30:49 -0500
commita4ba22fecc8db468377ab14f5652e4176f0488b7 (patch)
treee9fd4a001cda0cf06624f6fda54d92104fa4f011 /indra/llmessage/tests/test_llsdmessage_peer.py
parente1b0317c04124b4fc72f14dee1c2125cf970b0e0 (diff)
DRTVWR-418: Revamp testrunner to shutdown server Thread at end.
Instead of having testrunner.run()'s caller pass a Thread object on which to run the caller's server instance's serve_forever() method, just pass the server instance. testrunner.run() now constructs the Thread. This API change allows run() to also call shutdown() on the server instance when done, and then join() the Thread. The hope is that this will avoid the Python runtime forcing the process termination code to 1 due to forcibly killing the daemon thread still running serve_forever(). While at it, eliminate calls to testrunner.freeport() -- just make the runtime pick a suitable port instead.
Diffstat (limited to 'indra/llmessage/tests/test_llsdmessage_peer.py')
-rwxr-xr-xindra/llmessage/tests/test_llsdmessage_peer.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/indra/llmessage/tests/test_llsdmessage_peer.py b/indra/llmessage/tests/test_llsdmessage_peer.py
index bac18fa374..a0d5d1b354 100755
--- a/indra/llmessage/tests/test_llsdmessage_peer.py
+++ b/indra/llmessage/tests/test_llsdmessage_peer.py
@@ -36,7 +36,7 @@ from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from llbase.fastest_elementtree import parse as xml_parse
from llbase import llsd
-from testrunner import freeport, run, debug, VERBOSE
+from testrunner import run, debug, VERBOSE
import time
_storage=None
@@ -155,17 +155,13 @@ class Server(HTTPServer):
allow_reuse_address = False
if __name__ == "__main__":
- # Instantiate a Server(TestHTTPRequestHandler) on the first free port
- # in the specified port range. Doing this inline is better than in a
- # daemon thread: if it blows up here, we'll get a traceback. If it blew up
- # in some other thread, the traceback would get eaten and we'd run the
- # subject test program anyway.
- httpd, port = freeport(xrange(8000, 8020),
- lambda port: Server(('127.0.0.1', port), TestHTTPRequestHandler))
+ # Instantiate a Server(TestHTTPRequestHandler) on a port chosen by the
+ # runtime.
+ httpd = Server(('127.0.0.1', 0), TestHTTPRequestHandler)
# Pass the selected port number to the subject test program via the
# environment. We don't want to impose requirements on the test program's
# command-line parsing -- and anyway, for C++ integration tests, that's
# performed in TUT code rather than our own.
- os.environ["PORT"] = str(port)
+ os.environ["PORT"] = str(httpd.server_port)
debug("$PORT = %s", port)
- sys.exit(run(server=Thread(name="httpd", target=httpd.serve_forever), *sys.argv[1:]))
+ sys.exit(run(server_inst=httpd, *sys.argv[1:]))