code: def when_connected(self):
          
          if self._client and not self._client.is_closed:
              return defer.succeed(self._client)
          else:
              return self._client_deferred
docs: Retrieve the currently-connected Protocol, or the next one to connect.
  
          Returns:
              defer.Deferred: A Deferred that fires with a connected
                  :class:`FedoraMessagingProtocolV2` instance. This is similar to
                  the whenConnected method from the Twisted endpoints APIs, which
                  is sadly isn't available before 16.1.0, which isn't available
                  in EL7.