diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-04-25 22:26:08 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-04-25 22:26:08 (GMT) |
commit | e3123915297da3e87f6d62c0e0788a6b5421a5cf (patch) | |
tree | f29aeb87761b4ba6b87b9cfbc99b6bbbececee44 /Lib/test/test_httpservers.py | |
parent | d5781076ebff95e4d1a7054d77fb87041675baf1 (diff) | |
download | cpython-e3123915297da3e87f6d62c0e0788a6b5421a5cf.zip cpython-e3123915297da3e87f6d62c0e0788a6b5421a5cf.tar.gz cpython-e3123915297da3e87f6d62c0e0788a6b5421a5cf.tar.bz2 |
Merged revisions 80487,80489 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r80487 | antoine.pitrou | 2010-04-26 00:01:43 +0200 (lun., 26 avril 2010) | 12 lines
Merged revisions 80484 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r80484 | antoine.pitrou | 2010-04-25 23:40:32 +0200 (dim., 25 avril 2010) | 6 lines
Issue #2302: Fix a race condition in SocketServer.BaseServer.shutdown,
where the method could block indefinitely if called just before the
event loop started running. This also fixes the occasional freezes
witnessed in test_httpservers.
........
................
r80489 | antoine.pitrou | 2010-04-26 00:19:43 +0200 (lun., 26 avril 2010) | 9 lines
Merged revisions 80480 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r80480 | antoine.pitrou | 2010-04-25 23:15:50 +0200 (dim., 25 avril 2010) | 3 lines
Replace a Lock with a better suited Event.
........
................
Diffstat (limited to 'Lib/test/test_httpservers.py')
-rw-r--r-- | Lib/test/test_httpservers.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py index 4653f4c..aa1e48c 100644 --- a/Lib/test/test_httpservers.py +++ b/Lib/test/test_httpservers.py @@ -34,14 +34,14 @@ class TestServerThread(threading.Thread): threading.Thread.__init__(self) self.request_handler = request_handler self.test_object = test_object - self.test_object.lock.acquire() def run(self): self.server = HTTPServer(('', 0), self.request_handler) self.test_object.PORT = self.server.socket.getsockname()[1] - self.test_object.lock.release() + self.test_object.server_started.set() + self.test_object = None try: - self.server.serve_forever() + self.server.serve_forever(0.05) finally: self.server.server_close() @@ -51,13 +51,12 @@ class TestServerThread(threading.Thread): class BaseTestCase(unittest.TestCase): def setUp(self): - self.lock = threading.Lock() + self.server_started = threading.Event() self.thread = TestServerThread(self, self.request_handler) self.thread.start() - self.lock.acquire() + self.server_started.wait() def tearDown(self): - self.lock.release() self.thread.stop() def request(self, uri, method='GET', body=None, headers={}): |