rticommunity / rticonnextdds-connector

RTI Connector for Connext DDS is a lightweight technology that enables DDS data to be accessed with Javascript (Node.js), Python, and Lua.
Other
56 stars 33 forks source link

Main program terminate when using multi-thread subscription in PyQT #98

Closed MagicLee1001 closed 6 months ago

MagicLee1001 commented 6 months ago
_input_lock = threading.RLock()

class RtiDDSReader(threading.Thread):
    def __init__(self, connector, topic_name):
        super().__init__()
        self.connector = connector
        self.topic_name = topic_name
        self.input = self.connector.get_input(f'SoaSubscriber::Soa{self.topic_name}Reader')

    def run(self):
        while self.running:
        self.input.wait()  
        with _input_lock:
            self.input.take()
            for sample in self.input.samples.valid_data_iter:
            data = sample.get_dictionary()   # This could be the entrance to the termination

The threads that subscribe to these messages run in the background of my pyqt program and do not involve gui updates, but each time a certain number of messages are subscribed, the main program and these background threads terminate and exit without error codes.