Fixed stuff probably not being saved

This commit is contained in:
Pünkösd Marcell 2020-04-22 03:55:33 +02:00
parent 62d4bc48e8
commit 49d686a4ec

View File

@ -50,6 +50,8 @@ class ConsumerLocator:
return
consumer_list = self.red.consumerlist
for recconsumer in recievedconsumerlist:
contains = False
for consumer in self.red.consumerlist:
@ -57,8 +59,9 @@ class ConsumerLocator:
contains = True
if not contains:
self.red.consumerlist.append({"Host": recconsumer, "State": True, "LastOk": datetime.datetime.now().timestamp()})
consumer_list.append({"Host": recconsumer, "State": True, "LastOk": datetime.datetime.now().timestamp()})
self.red.consumerlist = consumer_list
self.updateconsumerlist()
def updateconsumerlist(self) -> None:
@ -70,7 +73,9 @@ class ConsumerLocator:
:return: None
"""
removelist = []
for consumer in self.red.consumerlist:
consumer_list = self.red.consumerlist
for consumer in consumer_list:
if not self.communicator.checkconsumer(consumer["Host"]):
consumer["State"] = False
if datetime.datetime.now() - datetime.datetime.fromtimestamp(consumer["LastOk"]) > datetime.timedelta(hours=1):
@ -79,7 +84,9 @@ class ConsumerLocator:
consumer["LastOk"] = datetime.datetime.now().timestamp()
consumer["State"] = True
for rem in removelist:
self.red.consumerlist.remove(rem)
consumer_list.remove(rem)
self.red.consumerlist = consumer_list
def updateconsumer(self):
"""If the current consumer is not available, checks all the consumers in the list and updates the current one.