Mercurial > code > home > repos > homeauto
changeset 562:82e9480c3b7d
fix a hang bug where polling stopped
Ignore-this: 7e3aaf37a2e0619c4b168cc424bf9c21
author | drewp@bigasterisk.com |
---|---|
date | Wed, 01 May 2019 00:24:13 -0700 |
parents | eca250fd66c7 |
children | 7f57d171d6d3 |
files | service/frontDoorLock/front_door_lock.py |
diffstat | 1 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/service/frontDoorLock/front_door_lock.py Wed May 01 00:09:54 2019 -0700 +++ b/service/frontDoorLock/front_door_lock.py Wed May 01 00:24:13 2019 -0700 @@ -79,7 +79,7 @@ self.timeUnlocked = None self.autoLockSec = 6 self.subj = ROOM['frontDoorLock'] - task.LoopingCall(self.check).start(1) + task.LoopingCall(self.pollCheck).start(1) def relock(self): log.info('autolock is up: requesting lock') @@ -90,9 +90,9 @@ g = self.masterGraph lockIn = self.autoLockSec - int(unlockedFor) if lockIn < 0: - tu = self.timeUnlocked - log.warn("timeUnlocked %(tu)r, state %(state)s, " - "unlockedFor %(unlockedFor)r, lockIn %(lockIn)r", vars()) + state = g._graph.value(self.subj, ROOM['state']) + log.warn(f"timeUnlocked {self.timeUnlocked}, state {state}, " + "unlockedFor {unlockedFor}, lockIn {lockIn}") lockIn = 0 g.patchObject(ctx, self.subj, ROOM['unlockedForSec'], Literal(int(unlockedFor))) @@ -103,6 +103,12 @@ g = self.masterGraph g.patchObject(ctx, self.subj, ROOM['unlockedForSec'], None) g.patchObject(ctx, self.subj, ROOM['autoLockInSec'], None) + + def pollCheck(self): + try: + self.check() + except Exception: + log.exception('poll failed') def check(self): g = self.masterGraph