Exemplo n.º 1
0
    def run(self):
        """ Starts Thread

            Runs as long as new data is available. If `acquire_data` returns
            `None` thread is terminated
        """
        for sample in self.acquire_data():
            if sample is None:
                print 'No new data available - shutting down data source'
                if self._abort is not None:
                    self._abort.set()
                break
            message = ArrayMessage(sample)
            self._publisher.queue.put(message.serialize(self.samplingrate))

            if self._abort is not None:
                if self._abort.is_set():
                    self._cleanup()
                    logging.info('{} - Abort event set. Exiting...'.format(
                        currentThread().getName()
                        ))
                    break