From 36272830d53d009941d45074e6e35c9d7d642fed Mon Sep 17 00:00:00 2001 From: schdwlk Date: Sun, 29 Mar 2020 18:00:00 +0200 Subject: [PATCH] Learn available consumers after switching current consumer --- consumerlocator.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/consumerlocator.py b/consumerlocator.py index fdb5d5d..540b6af 100644 --- a/consumerlocator.py +++ b/consumerlocator.py @@ -33,9 +33,10 @@ class ConsumerLocator: """" Learns the list of consumers. """ -#TODO improve learning - recievedConsumerList = self.communicator.discoveravailableconsumers() - for consumer in recievedConsumerList: + recievedconsumerlist = self.communicator.discoveravailableconsumers() + if recievedconsumerlist is None: + return + for consumer in recievedconsumerlist: self.consumerList.append({"Host": consumer, "State": True, "LastOk": datetime.datetime.now()}) self.updateConsumerList() @@ -71,6 +72,7 @@ class ConsumerLocator: break self.currentConsumer = newCurrentConsumer + self.learnconsumerlist() if self.currentConsumer is not None: return self.currentConsumer["Host"]