|
|
|
@ -43,6 +43,8 @@ import re |
|
|
|
|
import socket |
|
|
|
|
import subprocess |
|
|
|
|
import sys |
|
|
|
|
import tempfile |
|
|
|
|
import traceback |
|
|
|
|
import time |
|
|
|
|
import xml.etree.cElementTree as ET |
|
|
|
|
import urllib2 |
|
|
|
@ -704,35 +706,62 @@ def _start_port_server(port_server_port): |
|
|
|
|
urllib2.urlopen('http://localhost:%d/quitquitquit' % port_server_port).read() |
|
|
|
|
time.sleep(1) |
|
|
|
|
if not running: |
|
|
|
|
print 'starting port_server' |
|
|
|
|
port_log = open('portlog.txt', 'w') |
|
|
|
|
fd, logfile = tempfile.mkstemp() |
|
|
|
|
os.close(fd) |
|
|
|
|
print 'starting port_server, with log file %s' % logfile |
|
|
|
|
args = [sys.executable, 'tools/run_tests/port_server.py', '-p', '%d' % port_server_port, '-l', logfile] |
|
|
|
|
env = dict(os.environ) |
|
|
|
|
env['BUILD_ID'] = 'pleaseDontKillMeJenkins' |
|
|
|
|
if platform.system() == 'Windows': |
|
|
|
|
port_server = subprocess.Popen( |
|
|
|
|
args, |
|
|
|
|
env=env, |
|
|
|
|
creationflags = 0x00000008, # detached process |
|
|
|
|
close_fds=True) |
|
|
|
|
else: |
|
|
|
|
port_server = subprocess.Popen( |
|
|
|
|
[sys.executable, 'tools/run_tests/port_server.py', '-p', '%d' % port_server_port], |
|
|
|
|
stderr=subprocess.STDOUT, |
|
|
|
|
stdout=port_log) |
|
|
|
|
args, |
|
|
|
|
env=env, |
|
|
|
|
preexec_fn=os.setsid, |
|
|
|
|
close_fds=True) |
|
|
|
|
time.sleep(1) |
|
|
|
|
# ensure port server is up |
|
|
|
|
waits = 0 |
|
|
|
|
while True: |
|
|
|
|
if waits > 10: |
|
|
|
|
print 'killing port server due to excessive start up waits' |
|
|
|
|
port_server.kill() |
|
|
|
|
if port_server.poll() is not None: |
|
|
|
|
print 'port_server failed to start' |
|
|
|
|
port_log = open('portlog.txt', 'r').read() |
|
|
|
|
# try one final time: maybe another build managed to start one |
|
|
|
|
time.sleep(1) |
|
|
|
|
try: |
|
|
|
|
urllib2.urlopen('http://localhost:%d/get' % port_server_port, |
|
|
|
|
timeout=1).read() |
|
|
|
|
print 'last ditch attempt to contact port server succeeded' |
|
|
|
|
break |
|
|
|
|
except: |
|
|
|
|
traceback.print_exc(); |
|
|
|
|
port_log = open(logfile, 'r').read() |
|
|
|
|
print port_log |
|
|
|
|
sys.exit(1) |
|
|
|
|
try: |
|
|
|
|
urllib2.urlopen('http://localhost:%d/get' % port_server_port, |
|
|
|
|
timeout=1).read() |
|
|
|
|
print 'port server is up and ready' |
|
|
|
|
break |
|
|
|
|
except socket.timeout: |
|
|
|
|
print 'waiting for port_server: timeout' |
|
|
|
|
time.sleep(0.5) |
|
|
|
|
traceback.print_exc(); |
|
|
|
|
time.sleep(1) |
|
|
|
|
waits += 1 |
|
|
|
|
except urllib2.URLError: |
|
|
|
|
print 'waiting for port_server: urlerror' |
|
|
|
|
time.sleep(0.5) |
|
|
|
|
traceback.print_exc(); |
|
|
|
|
time.sleep(1) |
|
|
|
|
waits += 1 |
|
|
|
|
except: |
|
|
|
|
traceback.print_exc(); |
|
|
|
|
port_server.kill() |
|
|
|
|
raise |
|
|
|
|
|
|
|
|
|