code: def connection(self, handshake=None):
          
          if self._state == _State.CONNECTED:
              return succeed(self._current_client)
          elif self._state == _State.DISCONNECTING:
              return fail(ClientDisconnecting())
          elif self._state == _State.NOT_CONNECTED:
              d = self._notify_on_connect()
              self._connect(handshake)
              return d
          else:
              assert self._state == _State.CONNECTING
              return self._notify_on_connect()
docs: Connects if necessary, returns existing one if it can.
  
          :param handshake: A function to be called with the client
                            to complete the handshake.
  
          :returns: thrift connection, deferred if necessary