VOL-669 Openolt adapter - Fix a race condition in indication processing.

Change-Id: I6ca2771c90068098c6f6d792b2417c1f5071b3c6
diff --git a/voltha/adapters/openolt/openolt_device.py b/voltha/adapters/openolt/openolt_device.py
index 804bc0e..45faf77 100644
--- a/voltha/adapters/openolt/openolt_device.py
+++ b/voltha/adapters/openolt/openolt_device.py
@@ -84,18 +84,21 @@
         device.oper_status = OperStatus.ACTIVATING
         self.adapter_agent.update_device(device)
 
+
         # Initialize gRPC
         self.channel = grpc.insecure_channel(self.host_and_port)
-        self.stub = openolt_pb2_grpc.OpenoltStub(self.channel)
+        self.channel_ready_future = grpc.channel_ready_future(self.channel)
 
         # Start indications thread
-        self.indications_thread = threading.Thread(target=self.process_indication)
+        self.indications_thread = threading.Thread(target=self.process_indications)
         self.indications_thread.daemon = True
         self.indications_thread.start()
 
-    def process_indication(self):
+    def process_indications(self):
+        self.channel_ready_future.result() # blocks till gRPC connection is complete
+        self.stub = openolt_pb2_grpc.OpenoltStub(self.channel)
         self.indications = self.stub.EnableIndication(openolt_pb2.Empty())
-        while 1:
+        while True:
             # get the next indication from olt
             ind = next(self.indications)
             self.log.debug("rx indication", indication=ind)