'Callback for self._connection_attempt_timer: initiate connection
attempt in the context of the event loop'

def _on_connect_timer(self):

    self._connection_attempt_timer = None
    error = self._adapter_connect()
    if (not error):
        return self._on_connected()
    self.remaining_connection_attempts -= 1
    LOGGER.warning('Could    not    connect,    %i    attempts    left', self.remaining_connection_attempts)
    if (self.remaining_connection_attempts > 0):
        LOGGER.info('Retrying    in    %i    seconds', self.params.retry_delay)
        self._connection_attempt_timer = self.add_timeout(self.params.retry_delay, self._on_connect_timer)
    else:
        self.callbacks.process(0, self.ON_CONNECTION_ERROR, self, self, error)
        self.remaining_connection_attempts = self.params.connection_attempts
        self._set_connection_state(self.CONNECTION_CLOSED)
