'How to get thread-safety value from running thread in python class?

I have running thread like this self.thread = th.Thread(target=self.status)

def start(self):
    self.thread.start()
def status(self):
        while True:
            dict = {}
            for device in self._devices:
                dict[device.id] = device.get_results()
            self.status = dict
            if self.stop_thread:
                break

How can I thread-safety return self.status by another method using main thread?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source