Changeset 269514 in webkit
- Timestamp:
- Nov 6, 2020 9:08:04 AM (3 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r269513 r269514 1 2020-11-06 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 3 REGRESSION(r268930): It broke the http server of run-benchmark 4 https://bugs.webkit.org/show_bug.cgi?id=218643 5 6 Reviewed by Jonathan Bedard. 7 8 The http server was failing to start because it is executed in a 9 subprocess and it can't find webkitpy.autoinstalled because the 10 scripts dir is not in PYTHONPATH. 11 12 Fix this and also add a check to ensure the http server is alive, 13 and if not, then raise an error with the return code and outputs 14 from the http server process. 15 16 * Scripts/webkitpy/benchmark_runner/http_server_driver/http_server/twisted_http_server.py: 17 * Scripts/webkitpy/benchmark_runner/http_server_driver/simple_http_server_driver.py: 18 (SimpleHTTPServerDriver.serve): 19 (SimpleHTTPServerDriver): 20 (SimpleHTTPServerDriver._find_http_server_port): 21 1 22 2020-11-06 Carlos Alberto Lopez Perez <clopez@igalia.com> 2 23 -
trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/http_server/twisted_http_server.py
r268930 r269514 5 5 import os 6 6 import sys 7 8 # Since we execute this script directly as a subprocess, we need to ensure 9 # that Tools/Scripts is in sys.path for the next imports to work correctly. 10 script_dir = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), '../../../..')) 11 if script_dir not in sys.path: 12 sys.path.append(script_dir) 7 13 8 14 from pkg_resources import require, VersionConflict, DistributionNotFound -
trunk/Tools/Scripts/webkitpy/benchmark_runner/http_server_driver/simple_http_server_driver.py
r268930 r269514 34 34 interface_args.extend(['--interface', self._ip]) 35 35 self._server_process = subprocess.Popen(["python", http_server_path, web_root] + interface_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 36 37 36 max_attempt = 5 38 37 interval = 0.5 39 38 _log.info('Start to fetching the port number of the http server') 39 for attempt in range(max_attempt): 40 self._find_http_server_port() 41 if self._server_port: 42 _log.info('HTTP Server is serving at port: %d', self._server_port) 43 break 44 _log.info('Server port is not found this time, retry after %f seconds' % interval) 45 time.sleep(interval) 46 interval *= 2 47 else: 48 raise Exception("Server is not listening on port, max tries exceeded. HTTP server may be installing dependent modules.") 49 self._wait_for_http_server() 50 51 def _find_http_server_port(self): 52 if self._server_process.poll() is not None: 53 stdout_data, stderr_data = self._server_process.communicate() 54 raise RuntimeError('The http server terminated unexpectedly with return code {} and with the following output:\n{}'.format(self._server_process.returncode, stdout_data + stderr_data)) 40 55 try: 41 56 import psutil 42 for attempt in range(max_attempt): 43 connections = psutil.Process(self._server_process.pid).connections() 44 if connections and connections[0].laddr and connections[0].laddr[1] and connections[0].status == 'LISTEN': 45 self._server_port = connections[0].laddr[1] 46 _log.info('HTTP Server is serving at port: %d', self._server_port) 47 break 48 _log.info('Server port is not found this time, retry after %f seconds' % interval) 49 time.sleep(interval) 50 interval *= 2 51 else: 52 raise Exception("Server is not listening on port, max tries exceeded. HTTP server may be installing dependent modules.") 57 connections = psutil.Process(self._server_process.pid).connections() 58 if connections and connections[0].laddr and connections[0].laddr[1] and connections[0].status == 'LISTEN': 59 self._server_port = connections[0].laddr[1] 53 60 except ImportError: 54 for attempt in range(max_attempt): 55 try: 56 output = subprocess.check_output(['/usr/sbin/lsof', '-a', '-P', '-iTCP', '-sTCP:LISTEN', '-p', str(self._server_process.pid)]) 57 self._server_port = int(re.search('TCP .*:(\d+) \(LISTEN\)', output).group(1)) 58 if self._server_port: 59 _log.info('HTTP Server is serving at port: %d', self._server_port) 60 break 61 except Exception as error: 62 _log.info('Error: %s' % error) 63 _log.info('Server port is not found this time, retry after %f seconds' % interval) 64 time.sleep(interval) 65 interval *= 2 66 else: 67 raise Exception("Cannot listen to server, max tries exceeded") 68 self._wait_for_http_server() 61 try: 62 output = subprocess.check_output(['/usr/sbin/lsof', '-a', '-P', '-iTCP', '-sTCP:LISTEN', '-p', str(self._server_process.pid)]) 63 self._server_port = int(re.search(r'TCP .*:(\d+) \(LISTEN\)', output).group(1)) 64 except Exception as error: 65 _log.info('Error: %s' % error) 69 66 70 67 def _wait_for_http_server(self):
Note: See TracChangeset
for help on using the changeset viewer.