only .call() PollHooks when they're "due"

This commit is contained in:
jesopo 2019-10-10 14:12:58 +01:00
parent 1c792f0194
commit fd0baff093
2 changed files with 3 additions and 3 deletions

View file

@ -376,7 +376,8 @@ class Bot(object):
def _check(self):
for poll_timeout in self._poll_timeouts:
poll_timeout.call()
if poll_timeout.next() == 0:
poll_timeout.call()
throttle_filled = False
for server in list(self.servers.values()):

View file

@ -32,8 +32,7 @@ class LockFile(PollHook.PollHook):
def next(self):
return max(0, (self._next_lock-utils.datetime_utcnow()).total_seconds())
def call(self):
if self.next() == 0:
self.lock()
self.lock()
def unlock(self):
if os.path.isfile(self._lock_location):