summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Lib/test/test_xmlrpc.py33
1 files changed, 19 insertions, 14 deletions
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 4dd3316..738db8a 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -296,6 +296,9 @@ class BinaryTestCase(unittest.TestCase):
PORT = None
+# The evt is set twice. First when the server is ready to serve.
+# Second when the server has been shutdown. The user must clear
+# the event after it has been set the first time to catch the second set.
def http_server(evt, numrequests):
class TestInstanceClass:
def div(self, x, y):
@@ -323,6 +326,7 @@ def http_server(evt, numrequests):
serv.register_function(lambda x,y: x+y, 'add')
serv.register_function(my_function)
serv.register_instance(TestInstanceClass())
+ evt.set()
# handle up to 'numrequests' requests
while numrequests > 0:
@@ -336,10 +340,19 @@ def http_server(evt, numrequests):
PORT = None
evt.set()
+# TODO(nnorwitz): 25-Jan-2008 since we now notify the test when the server
+# is totally ready to serve, this function should not be necessary.
+# It is disabled by returning False. If the buildbots don't show any
+# failures for this test over the next week, all the code associated
+# with this function should be removed. The code that needs to be removed
+# is this function, the NOTE below, and the entire except body that
+# calls this function.
def is_unavailable_exception(e):
'''Returns True if the given ProtocolError is the product of a server-side
exception caused by the 'temporarily unavailable' response sometimes
given by operations on non-blocking sockets.'''
+ return False
+
# sometimes we get a -1 error code and/or empty headers
if e.errcode == -1 or e.headers is None:
return True
@@ -367,13 +380,9 @@ class SimpleServerTestCase(unittest.TestCase):
serv_args = (self.evt, 1)
threading.Thread(target=http_server, args=serv_args).start()
- # wait for port to be assigned to server
- n = 1000
- while n > 0 and PORT is None:
- time.sleep(0.001)
- n -= 1
-
- time.sleep(0.5)
+ # wait for the server to be ready
+ self.evt.wait()
+ self.evt.clear()
def tearDown(self):
# wait on the server thread to terminate
@@ -518,13 +527,9 @@ class FailingServerTestCase(unittest.TestCase):
serv_args = (self.evt, 2)
threading.Thread(target=http_server, args=serv_args).start()
- # wait for port to be assigned to server
- n = 1000
- while n > 0 and PORT is None:
- time.sleep(0.001)
- n -= 1
-
- time.sleep(0.5)
+ # wait for the server to be ready
+ self.evt.wait()
+ self.evt.clear()
def tearDown(self):
# wait on the server thread to terminate