diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-04-25 21:15:50 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-04-25 21:15:50 (GMT) |
commit | 1ca8c19b65637d292e3d10408ee6243447ec550a (patch) | |
tree | 09017275ee1b1d6cf09b35e2e47ce248b633c832 | |
parent | 5c322ece9601da2a4113f489d44762abffe6b8cd (diff) | |
download | cpython-1ca8c19b65637d292e3d10408ee6243447ec550a.zip cpython-1ca8c19b65637d292e3d10408ee6243447ec550a.tar.gz cpython-1ca8c19b65637d292e3d10408ee6243447ec550a.tar.bz2 |
Replace a Lock with a better suited Event.
-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 287ad53..e392aee 100644 --- a/Lib/test/test_httpservers.py +++ b/Lib/test/test_httpservers.py @@ -33,14 +33,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() @@ -52,13 +52,12 @@ class BaseTestCase(unittest.TestCase): def setUp(self): self._threads = test_support.threading_setup() os.environ = test_support.EnvironmentVarGuard() - 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() os.environ.__exit__() test_support.threading_cleanup(*self._threads) |