def __exec_cop()

in tsqa/environment.py [0:0]


    def __exec_cop(self):
        path = os.path.join(self.layout.bindir, 'traffic_cop')
        cmd = [path, '--debug', '--stdout']

        with open(os.path.join(self.layout.logdir, 'cop.log'), 'w+') as logfile:
            self.cop = subprocess.Popen(
                cmd,
                env=self.shell_env,
                stdout=logfile,
                stderr=logfile,
            )
            start = time.time()
            # TODO: more specific exception?
            try:
                tsqa.utils.poll_interfaces(self.hostports)
            except:
                self.stop()  # make sure to stop the daemons
                raise
            log.debug('traffic_cop took {0}s to start up'.format(time.time() - start))

            self.cop.poll()
            if self.cop.returncode is not None:
                raise Exception(self.cop.returncode, self.layout.prefix)