| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """A "Test Server Spawner" that handles killing/stopping per-test test servers. | 5 """A "Test Server Spawner" that handles killing/stopping per-test test servers. |
| 6 | 6 |
| 7 It's used to accept requests from the device to spawn and kill instances of the | 7 It's used to accept requests from the device to spawn and kill instances of the |
| 8 chrome test server on the host. | 8 chrome test server on the host. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 if device_port and _CheckDevicePortStatus(self.adb, device_port): | 249 if device_port and _CheckDevicePortStatus(self.adb, device_port): |
| 250 self.is_ready = True | 250 self.is_ready = True |
| 251 self.forwarder_device_port = device_port | 251 self.forwarder_device_port = device_port |
| 252 # Wake up the request handler thread. | 252 # Wake up the request handler thread. |
| 253 self.ready_event.set() | 253 self.ready_event.set() |
| 254 # Keep thread running until Stop() gets called. | 254 # Keep thread running until Stop() gets called. |
| 255 _WaitUntil(lambda: self.stop_flag, max_attempts=sys.maxint) | 255 _WaitUntil(lambda: self.stop_flag, max_attempts=sys.maxint) |
| 256 if self.process.poll() is None: | 256 if self.process.poll() is None: |
| 257 self.process.kill() | 257 self.process.kill() |
| 258 if self._test_server_forwarder: | 258 if self._test_server_forwarder: |
| 259 self._test_server_forwarder.Close() | 259 self._test_server_forwarder.UnmapDevicePort(self.forwarder_device_port) |
| 260 self.process = None | 260 self.process = None |
| 261 self.is_ready = False | 261 self.is_ready = False |
| 262 if self.pipe_out: | 262 if self.pipe_out: |
| 263 os.close(self.pipe_in) | 263 os.close(self.pipe_in) |
| 264 os.close(self.pipe_out) | 264 os.close(self.pipe_out) |
| 265 self.pipe_in = None | 265 self.pipe_in = None |
| 266 self.pipe_out = None | 266 self.pipe_out = None |
| 267 logging.info('Test-server has died.') | 267 logging.info('Test-server has died.') |
| 268 self.wait_event.set() | 268 self.wait_event.set() |
| 269 | 269 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 | 423 |
| 424 def CleanupState(self): | 424 def CleanupState(self): |
| 425 """Cleans up the spawning server state. | 425 """Cleans up the spawning server state. |
| 426 | 426 |
| 427 This should be called if the test server spawner is reused, | 427 This should be called if the test server spawner is reused, |
| 428 to avoid sharing the test server instance. | 428 to avoid sharing the test server instance. |
| 429 """ | 429 """ |
| 430 if self.server.test_server_instance: | 430 if self.server.test_server_instance: |
| 431 self.server.test_server_instance.Stop() | 431 self.server.test_server_instance.Stop() |
| 432 self.server.test_server_instance = None | 432 self.server.test_server_instance = None |
| OLD | NEW |