import threading


class ScaleEvent(object):
    def __init__(self):
        self.event = threading.Event()
        self.weight = None

    def get_weight(self):
        return self.weight

    def set_weight(self, weight):
        self.weight = weight
        self.event.set()

    def clear_weight(self):
        self.weight = None
        self.event.clear()

    def wait(self, timeout):
        self.event.wait(timeout)
        self.event.clear()
