diff --git a/consumerlocator.py b/consumerlocator.py index 4c727e5..6226f2d 100644 --- a/consumerlocator.py +++ b/consumerlocator.py @@ -33,7 +33,7 @@ class ConsumerLocator: :param communicator: the :class:'communicator.Communicator' instance that will be used for the low level communication. """ self.red = redisconnector - self.red.consumerlist = [{"Host": KNOWNCONSUMER, "State": True, "LastOk": datetime.datetime.now()}] + self.red.consumerlist = [{"Host": KNOWNCONSUMER, "State": True, "LastOk": datetime.datetime.now().timestamp()}] self.red.currentconsumer = self.red.consumerlist[0] self.communicator = communicator @@ -55,7 +55,7 @@ class ConsumerLocator: contains = True if not contains: - self.red.consumerlist.append({"Host": recconsumer, "State": True, "LastOk": datetime.datetime.now()}) + self.red.consumerlist.append({"Host": recconsumer, "State": True, "LastOk": datetime.datetime.now().timestamp()}) self.updateconsumerlist() @@ -71,10 +71,10 @@ class ConsumerLocator: for consumer in self.red.consumerlist: if not self.communicator.checkconsumer(consumer["Host"]): consumer["State"] = False - if datetime.datetime.now() - consumer["LastOk"] > datetime.timedelta(hours=1): + if datetime.datetime.now() - datetime.datetime.fromtimestamp(consumer["LastOk"]) > datetime.timedelta(hours=1): removelist.append(consumer) else: - consumer["LastOk"] = datetime.datetime.now() + consumer["LastOk"] = datetime.datetime.now().timestamp() consumer["State"] = True for rem in removelist: self.red.consumerlist.remove(rem)