Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion code/stuff/fake_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,23 @@ def run(self):
class FakeSensor:
def __init__(self):
thread = threading.Thread(target=self.run)
thread.daemon = True
thread.daemon = False
thread.start()
self.cv = threading.Condition()
with self.cv:
self.cv.wait()

def run(self):
self.sensor = ActualFakeSensor()
with self.cv:
self.cv.notify()
self.sensor.run()

def value(self):
return self.sensor.value()

def register_callback(self, callback):
self.sensor.register_callback(callback)

if __name__ == '__main__':
sensor = FakeSensor()
Expand Down