Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/servers/server_base.py

Issue 2624093003: Remove the overridden _stop_running_server method in WPTServe. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (C) 2011 Google Inc. All rights reserved. 1 # Copyright (C) 2011 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 14 matching lines...) Expand all
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 """Base class used to start servers used by the layout tests.""" 29 """Base class used to start servers used by the layout tests."""
30 30
31 import errno 31 import errno
32 import logging 32 import logging
33 import socket 33 import socket
34 import tempfile 34 import tempfile
35 import time
36 35
37 36
38 _log = logging.getLogger(__name__) 37 _log = logging.getLogger(__name__)
39 38
40 39
41 class ServerError(Exception): 40 class ServerError(Exception):
42 pass 41 pass
43 42
44 43
45 class ServerBase(object): 44 class ServerBase(object):
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 else: 223 else:
225 _log.error('%s error log empty', self._name) 224 _log.error('%s error log empty', self._name)
226 _log.error('') 225 _log.error('')
227 else: 226 else:
228 _log.error('%s no error log', self._name) 227 _log.error('%s no error log', self._name)
229 228
230 def _wait_for_action(self, action, wait_secs=20.0, sleep_secs=1.0): 229 def _wait_for_action(self, action, wait_secs=20.0, sleep_secs=1.0):
231 """Repeat the action for wait_sec or until it succeeds, sleeping for sle ep_secs 230 """Repeat the action for wait_sec or until it succeeds, sleeping for sle ep_secs
232 in between each attempt. Returns whether it succeeded. 231 in between each attempt. Returns whether it succeeded.
233 """ 232 """
234 start_time = time.time() 233 start_time = self._port_obj.host.time()
235 while time.time() - start_time < wait_secs: 234 while self._port_obj.host.time() - start_time < wait_secs:
236 if action(): 235 if action():
237 return True 236 return True
238 _log.debug("Waiting for action: %s", action) 237 _log.debug("Waiting for action: %s", action)
239 time.sleep(sleep_secs) 238 self._port_obj.host.sleep(sleep_secs)
240 239
241 return False 240 return False
242 241
243 def _is_server_running_on_all_ports(self): 242 def _is_server_running_on_all_ports(self):
244 """Returns whether the server is running on all the desired ports.""" 243 """Returns whether the server is running on all the desired ports."""
245 244
246 # TODO(dpranke): crbug/378444 maybe pid is unreliable on win? 245 # TODO(dpranke): crbug/378444 maybe pid is unreliable on win?
247 if not self._platform.is_win() and not self._executive.check_running_pid (self._pid): 246 if not self._platform.is_win() and not self._executive.check_running_pid (self._pid):
248 _log.debug("Server isn't running at all") 247 _log.debug("Server isn't running at all")
249 self._log_errors_from_subprocess() 248 self._log_errors_from_subprocess()
(...skipping 25 matching lines...) Expand all
275 except IOError as error: 274 except IOError as error:
276 if error.errno in (errno.EALREADY, errno.EADDRINUSE): 275 if error.errno in (errno.EALREADY, errno.EADDRINUSE):
277 raise ServerError('Port %d is already in use.' % port) 276 raise ServerError('Port %d is already in use.' % port)
278 elif self._platform.is_win() and error.errno in (errno.WSAEACCES ,): # pylint: disable=no-member 277 elif self._platform.is_win() and error.errno in (errno.WSAEACCES ,): # pylint: disable=no-member
279 raise ServerError('Port %d is already in use.' % port) 278 raise ServerError('Port %d is already in use.' % port)
280 else: 279 else:
281 raise 280 raise
282 finally: 281 finally:
283 s.close() 282 s.close()
284 _log.debug('all ports are available') 283 _log.debug('all ports are available')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698