def _setup_pubsub(self):
     # Supscribe to published signals
     for publisher_topic in self.publisher_topics():
         self._subscribers[publisher_topic] = \
                 Subscriber(self._published_signals, topic=publisher_topic)
     for subscriber in self._subscribers:
         self._subscribers[subscriber].open()
     # Allow tests to publish to subscribers in service
     for subscriber_topic in self.subscriber_topics():
         self._publishers[subscriber_topic] = \
                 Publisher(topic=subscriber_topic)
     for publisher in self._publishers:
         self._publishers[publisher].open()
Exemplo n.º 2
0
    def __create_publisher(self, topic):
        self.logger.info('creating new publisher for "{}"'.format(topic))
        publisher = Publisher(topic=topic)

        try:
            publisher.open(
                on_connected=self.conn_on_connected,
                on_disconnected=self.conn_on_disconnected)
        except TypeError as e:
            self.logger.warning(
                'Connecting to an outdated communication module')
            # try previous interface
            publisher.open()
            # no need to configure connectivity if not supported
            return publisher

        self.conn_configure(publisher.is_connected)
        return publisher