diff options
author | Jürg Billeter <j@bitron.ch> | 2019-09-03 13:36:36 +0200 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-09-03 15:00:43 +0000 |
commit | d2e867280ed6667c0b253a2baa43555fb75f8783 (patch) | |
tree | 3ffe7eea859f9332afdb8cc6221157bc801f6082 | |
parent | 6cfe9f356c13170aaf4e1f67d5f5e81c9a3194a2 (diff) | |
download | buildstream-juerg/http-test-server.tar.gz |
tests/testutils/http_server.py: Drop queue to avoid lingering threadjuerg/http-test-server
Some CI jobs still sporadically encounter a thread that wasn't cleaned
up in tests that use the HTTP server, despite calling Queue.close() and
Queue.join_thread().
As a simple SIGTERM signal should suffice to properly terminate the HTTP
server child process, this simply removes the queue and also the extra
thread for serving requests.
-rw-r--r-- | tests/testutils/http_server.py | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/tests/testutils/http_server.py b/tests/testutils/http_server.py index 6ecb7b5b3..b72e745c5 100644 --- a/tests/testutils/http_server.py +++ b/tests/testutils/http_server.py @@ -2,7 +2,6 @@ import multiprocessing import os import posixpath import html -import threading import base64 from http.server import SimpleHTTPRequestHandler, HTTPServer, HTTPStatus @@ -84,7 +83,6 @@ class AuthHTTPServer(HTTPServer): class SimpleHttpServer(multiprocessing.Process): def __init__(self): - self.__stop = multiprocessing.Queue() super().__init__() self.server = AuthHTTPServer(('127.0.0.1', 0), RequestHandler) self.started = False @@ -94,20 +92,13 @@ class SimpleHttpServer(multiprocessing.Process): super().start() def run(self): - t = threading.Thread(target=self.server.serve_forever) - t.start() - self.__stop.get() - self.server.shutdown() - t.join() + self.server.serve_forever() def stop(self): if not self.started: return - self.__stop.put(None) self.terminate() self.join() - self.__stop.close() - self.__stop.join_thread() def allow_anonymous(self, cwd): self.server.anonymous_dir = cwd |