diff options
author | Brad King <brad.king@kitware.com> | 2020-08-31 16:53:18 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-08-31 16:53:26 (GMT) |
commit | eb7e20db39e2a745883084455e41c4d24b6bf5d1 (patch) | |
tree | 71bc857318e71c9ac3935ecb63d5e1281553c037 /Tests | |
parent | 5294febcaf378589dba49801321d19f93f67464e (diff) | |
parent | beab8bc29aa9938df3bf90fe5a50f926080765ed (diff) | |
download | CMake-eb7e20db39e2a745883084455e41c4d24b6bf5d1.zip CMake-eb7e20db39e2a745883084455e41c4d24b6bf5d1.tar.gz CMake-eb7e20db39e2a745883084455e41c4d24b6bf5d1.tar.bz2 |
Merge topic 'ExternalProject-test-download-timeout'
beab8bc29a Tests: Add timeout on the RunCMake.ExternalProject download server
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5167
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/ExternalProject/DownloadServer.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Tests/RunCMake/ExternalProject/DownloadServer.py b/Tests/RunCMake/ExternalProject/DownloadServer.py index ac0769f..3738317 100644 --- a/Tests/RunCMake/ExternalProject/DownloadServer.py +++ b/Tests/RunCMake/ExternalProject/DownloadServer.py @@ -4,6 +4,7 @@ import time import subprocess import sys import os +import threading args = None outerthread = None @@ -25,6 +26,13 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): self.wfile.write(data) self.close_connection = True +def runServer(fileName): + httpd = HTTPServer(('localhost', 0), SimpleHTTPRequestHandler) + with open(fileName,"w") as f: + f.write('http://localhost:{}/test'.format(httpd.socket.getsockname()[1])) + httpd.handle_request() + os.remove(fileName) + if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('--speed_limit', help='transfer rate limitation', action='store_true',default=False) @@ -35,8 +43,7 @@ if __name__ == "__main__": if not args.subprocess: subprocess.Popen([sys.executable]+sys.argv+['--subprocess'],stdin=subprocess.DEVNULL, stderr=subprocess.DEVNULL,stdout=subprocess.DEVNULL) else: - httpd = HTTPServer(('localhost', 0), SimpleHTTPRequestHandler) - with open(args.file,"w") as f: - f.write('http://localhost:{}/test'.format(httpd.socket.getsockname()[1])) - httpd.handle_request() - os.remove(args.file) + serverThread = threading.Thread(target=runServer,args=(args.file,)) + serverThread.daemon = True + serverThread.start() + serverThread.join(15) |