diff --git a/lptest.py b/lptest.py
index <HASH>..<HASH> 100644
--- a/lptest.py
+++ b/lptest.py
@@ -87,11 +87,13 @@ class ServerThread(threading.Thread):
     def __init__(self, numtests):
         super(ServerThread, self).__init__()
         self.numtests = numtests
+        self.ready = threading.Event()
     def run(self):
         server = BaseHTTPServer.HTTPServer
         bind_to = ('', 8091)
         reqhandler = Handler
         httpd = server(bind_to, reqhandler)
+        self.ready.set()
         for i in xrange(self.numtests):
             httpd.handle_request()
 
@@ -349,6 +351,9 @@ server = ServerThread(numtests)
 server.setDaemon(True)
 server.start()
 
+# Wait for the server thread to signal that it's ready
+server.ready.wait()
+
 testsuite = unittest.TestSuite()
 testloader = unittest.TestLoader()
 testsuite.addTest(testloader.loadTestsFromTestCase(TestCases))
Add an Event to signal the server thread is ready

Due to a problem with threading, the unit tests would begin running
before the webserver was ready to receive localhost URL requests.
In Python 3 on my machine there would be an error once every <I>
runs or so; with this code I'm unable to recreate the problem even
after tens of thousands of runs. I believe the problem is fixed.