Mercurial > code > home > repos > homeauto
changeset 476:e1f33b9fb3df
fix hang-at-startup bug
Ignore-this: 1ad778b512970dd9a582e7f66b93ddcd
author | drewp@bigasterisk.com |
---|---|
date | Sat, 20 Apr 2019 23:54:11 -0700 |
parents | b264ca970aba |
children | 498f5cc6fc33 |
files | service/rfid_pn532_py/rfid.py |
diffstat | 1 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/service/rfid_pn532_py/rfid.py Sat Apr 20 23:53:43 2019 -0700 +++ b/service/rfid_pn532_py/rfid.py Sat Apr 20 23:54:11 2019 -0700 @@ -100,8 +100,11 @@ self.pollPeriodSecs = .1 self.expireSecs = 5 - - task.LoopingCall(self.poll).start(self.pollPeriodSecs) + + # now=False avoids a serious bug where the first read error + # could happen before reactor.run() is called, and then the + # error fails to crash the reactor and get us restarted. + task.LoopingCall(self.poll).start(self.pollPeriodSecs, now=False) @STATS.cardReadPoll.time() def poll(self): @@ -138,6 +141,7 @@ traceback.print_exc() log.error(e) reactor.stop() + def flushOldReads(self, now): for uri in list(self.log): if self.log[uri] < now - self.expireSecs: