Skip to content

Commit

Permalink
Fix timing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Jun 10, 2016
1 parent 20427d9 commit 6bd626c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/automate/sensors/builtin_sensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import queue
from copy import deepcopy

from datetime import datetime
from datetime import datetime, timedelta

from croniter import croniter
from traits.api import Any, CInt, CFloat, Unicode, CUnicode, List, CBool, Instance, CStr, Int
Expand Down Expand Up @@ -226,7 +226,8 @@ def _setup_next_update(self, next_update_time):
if self._update_timer and self._update_timer.is_alive():
self._update_timer.cancel()

delay = next_update_time - now
delay = next_update_time - now + timedelta(seconds=1)
self.logger.warning('SETTING TIMER %s to %s, %s seconds, at %s', self, delay, delay.seconds, now+delay)
self._update_timer = threading.Timer(delay.seconds, threaded(self.update_status,))
self._update_timer.name = ("Timer for TimerSensor " + self.name + " at %s" % (now + delay))
self._update_timer.start()
Expand Down

0 comments on commit 6bd626c

Please sign in to comment.