Fix overlapping reconnect loops

Change-Id: I23f5c17700f9ac17baf9c8136739bf32d656bbf0
diff --git a/grpc_client/grpc_client.py b/grpc_client/grpc_client.py
index 72c8e47..e9ce5c6 100644
--- a/grpc_client/grpc_client.py
+++ b/grpc_client/grpc_client.py
@@ -59,10 +59,12 @@
         self.retries = 0
         self.on_reconnect = None
         self.shutting_down = False
+        self.connected = False
 
     def run(self, on_reconnect=None):
         self.on_reconnect = on_reconnect
-        reactor.callLater(0, self.connect)
+        if not self.connected:
+            reactor.callLater(0, self.connect)
         return self
 
     def shutdown(self):
@@ -77,7 +79,7 @@
         (Re-)Connect to end-point
         """
 
-        if self.shutting_down:
+        if self.shutting_down or self.connected:
             return
 
         try:
@@ -93,6 +95,7 @@
             self._compile_proto_files()
             self._clear_backoff()
 
+            self.connected = True
             if self.on_reconnect is not None:
                 reactor.callLater(0, self.on_reconnect)
 
@@ -236,7 +239,7 @@
         :return: The response protobuf message
         """
 
-        if self.channel is None:
+        if not self.connected:
             raise ServiceUnavailable()
 
         try:
@@ -249,7 +252,8 @@
             else:
                 log.exception(e)
 
-            self.channel = None
-            reactor.callLater(0, self.connect)
+            if self.connected :
+                self.connected = False
+                reactor.callLater(0, self.connect)
 
             raise e