mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-26 00:00:39 -05:00
Tests: Add timeout on the RunCMake.ExternalProject download server
Fixes: #21132
This commit is contained in:
committed by
Brad King
parent
efdd143459
commit
beab8bc29a
@@ -4,6 +4,7 @@ import time
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import threading
|
||||||
args = None
|
args = None
|
||||||
outerthread = None
|
outerthread = None
|
||||||
|
|
||||||
@@ -25,6 +26,13 @@ class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
|
|||||||
self.wfile.write(data)
|
self.wfile.write(data)
|
||||||
self.close_connection = True
|
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__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--speed_limit', help='transfer rate limitation', action='store_true',default=False)
|
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:
|
if not args.subprocess:
|
||||||
subprocess.Popen([sys.executable]+sys.argv+['--subprocess'],stdin=subprocess.DEVNULL, stderr=subprocess.DEVNULL,stdout=subprocess.DEVNULL)
|
subprocess.Popen([sys.executable]+sys.argv+['--subprocess'],stdin=subprocess.DEVNULL, stderr=subprocess.DEVNULL,stdout=subprocess.DEVNULL)
|
||||||
else:
|
else:
|
||||||
httpd = HTTPServer(('localhost', 0), SimpleHTTPRequestHandler)
|
serverThread = threading.Thread(target=runServer,args=(args.file,))
|
||||||
with open(args.file,"w") as f:
|
serverThread.daemon = True
|
||||||
f.write('http://localhost:{}/test'.format(httpd.socket.getsockname()[1]))
|
serverThread.start()
|
||||||
httpd.handle_request()
|
serverThread.join(15)
|
||||||
os.remove(args.file)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user