More careful about traffic_cop stopping
Project: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/commit/9bc0c2ff Tree: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/tree/9bc0c2ff Diff: http://git-wip-us.apache.org/repos/asf/trafficserver-qa/diff/9bc0c2ff Branch: refs/heads/master Commit: 9bc0c2ffe6530653008739fd412dd4aae1197aa1 Parents: 6c5e66c Author: Thomas Jackson <[email protected]> Authored: Fri Jan 23 15:49:44 2015 -0800 Committer: Thomas Jackson <[email protected]> Committed: Fri Jan 23 15:49:44 2015 -0800 ---------------------------------------------------------------------- tsqa/environment.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver-qa/blob/9bc0c2ff/tsqa/environment.py ---------------------------------------------------------------------- diff --git a/tsqa/environment.py b/tsqa/environment.py index e1bf9fa..7af94bb 100644 --- a/tsqa/environment.py +++ b/tsqa/environment.py @@ -385,11 +385,18 @@ class Environment: log.debug("Started traffic cop: %s", self.cop) # TODO: exception if already stopped? - # TODO: more graceful stop? def stop(self): - log.debug("Killing traffic cop: %s", self.cop) - if self.cop is not None: + log.debug("Stopping traffic cop: %s", self.cop) + if self.running(): self.cop.kill() + # wait for a max of 2s + stoptime = time.time() + 2 + while time.time() < stoptime: + # if we got a returncode, we exited + if self.cop.poll() is not None: + return + time.sleep(0.1) + log.error('Unable to stop traffic_cop: {0}'.format(self.cop)) self.cop.terminate() # TODO: remove?? or wait... def running(self):
