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