# Path: xwing/exceptions.py
# class MaxRetriesExceededError(Exception):
#     pass


import asyncio
import logging
from xwing.exceptions import MaxRetriesExceededError
        self.loop = loop
        self.settings = settings
        self.client_factory = client_factory
        self.clients = {}

    async def connect(self, pid):
        hub_frontend, identity = pid
        if hub_frontend not in self.clients:
            self.clients[hub_frontend] = self.create_client(hub_frontend)

        client = self.clients[hub_frontend]
        return await self.connect_client(client, identity)

    async def connect_client(self, client, remote_identity, max_retries=30,
                             retry_sleep=0.1):
        log.info('Creating connection to %s' % remote_identity)
        connection = None
        number_of_retries = 0
        while number_of_retries < max_retries:
            try:
                connection = await client.connect(remote_identity)
            except ConnectionError:
                log.info('Retrying connection to %s...' % remote_identity)
                number_of_retries += 1
                await asyncio.sleep(retry_sleep)
                continue
            else:
                break

        if not connection:

# Path: xwing/exceptions.py
# class MaxRetriesExceededError(Exception):
#     pass


# Path: xwing/network/outbound.py
import asyncio
import logging
from xwing.exceptions import MaxRetriesExceededError

        self.loop = loop
        self.settings = settings
        self.client_factory = client_factory
        self.clients = {}

    async def connect(self, pid):
        hub_frontend, identity = pid
        if hub_frontend not in self.clients:
            self.clients[hub_frontend] = self.create_client(hub_frontend)

        client = self.clients[hub_frontend]
        return await self.connect_client(client, identity)

    async def connect_client(self, client, remote_identity, max_retries=30,
                             retry_sleep=0.1):
        log.info('Creating connection to %s' % remote_identity)
        connection = None
        number_of_retries = 0
        while number_of_retries < max_retries:
            try:
                connection = await client.connect(remote_identity)
            except ConnectionError:
                log.info('Retrying connection to %s...' % remote_identity)
                number_of_retries += 1
                await asyncio.sleep(retry_sleep)
                continue
            else:
                break

        if not connection:

            raise MaxRetriesExceededError