flake8 and string formatting

This commit is contained in:
Jannes Höke 2016-01-04 02:05:39 +01:00
parent 81b58c7d00
commit 87657bcd70

View file

@ -25,9 +25,9 @@ import time
from threading import Thread, Lock from threading import Thread, Lock
try: try:
from queue import Queue, PriorityQueue from queue import PriorityQueue
except ImportError: except ImportError:
from Queue import Queue, PriorityQueue from Queue import PriorityQueue
class JobQueue(object): class JobQueue(object):
@ -81,8 +81,7 @@ class JobQueue(object):
next_t += time.time() next_t += time.time()
self.logger.debug("Putting a {} with t={}".format( self.logger.debug("Putting a %s with t=%f" % (job.name, next_t))
job.name, next_t))
self.queue.put((next_t, job)) self.queue.put((next_t, job))
def tick(self): def tick(self):
@ -91,20 +90,19 @@ class JobQueue(object):
""" """
now = time.time() now = time.time()
self.logger.debug("Ticking jobs with t={}".format(now)) self.logger.debug("Ticking jobs with t=%f" % now)
while not self.queue.empty(): while not self.queue.empty():
t, j = self.queue.queue[0] t, j = self.queue.queue[0]
self.logger.debug("Peeked at {} with t={}".format( self.logger.debug("Peeked at %s with t=%f" % (j.name, t))
j.name, t))
if t < now: if t < now:
self.queue.get() self.queue.get()
self.logger.info("Running job {}".format(j.name)) self.logger.info("Running job %s" % j.name)
try: try:
j.run(self.bot) j.run(self.bot)
except: except:
self.logger.exception("An uncaught error was raised while " self.logger.exception("An uncaught error was raised while "
"executing job {}".format(j.name)) "executing job %s" % j.name)
if j.repeat: if j.repeat:
self.put(j.run, j.interval) self.put(j.run, j.interval)
continue continue