comparison py/fridge.py @ 162:d73077e8cd67

Add daemon mode with locking, add "disabled" parameter
author Matt Johnston <matt@ucc.asn.au>
date Fri, 11 Jan 2013 23:41:56 +0800
parents a6612745b4a3
children bf2a17873ba1
comparison
equal deleted inserted replaced
161:ad22db765ba1 162:d73077e8cd67
48 % (self.value_file.name, buf)) 48 % (self.value_file.name, buf))
49 return True 49 return True
50 50
51 # greenlet subclassed 51 # greenlet subclassed
52 def _run(self): 52 def _run(self):
53 if self.server.params.disabled:
54 L("Fridge is disabled")
53 while True: 55 while True:
54 self.do() 56 self.do()
55 gevent.sleep(config.FRIDGE_SLEEP) 57 gevent.sleep(config.FRIDGE_SLEEP)
56 58
57 def do(self): 59 def do(self):
67 69
68 off_time = self.server.now() - self.fridge_off_clock 70 off_time = self.server.now() - self.fridge_off_clock
69 71
70 if off_time < config.FRIDGE_DELAY: 72 if off_time < config.FRIDGE_DELAY:
71 L("fridge skipping, too early") 73 L("fridge skipping, too early")
74 return
75
76 if params.disabled:
77 if self.is_on():
78 L("Disabled, turning fridge off")
79 self.off()
72 return 80 return
73 81
74 # handle broken wort sensor 82 # handle broken wort sensor
75 if wort is not None: 83 if wort is not None:
76 self.wort_valid_clock = self.server.now() 84 self.wort_valid_clock = self.server.now()