Exemplo n.º 1
0
    def connection_lost(self, exc):
        self._is_connected = False
        self.transport = None

        # Raise exception on all waiting futures.
        for f in self.__queries.values():
            f.set_exception(ConnectionLostError(exc))

        logger.log(logging.INFO, 'Mongo connection lost')

        if self.__connection_lost_callback:
            self.__connection_lost_callback(exc)
Exemplo n.º 2
0
    def connection_lost(self, exc):
        self._is_connected = False
        self.transport = None

        # Raise exception on all waiting futures.
        for f in self.__queries.values():
            f.set_exception(ConnectionLostError(exc))

        logger.log(logging.INFO, 'Mongo connection lost')

        if self.__connection_lost_callback:
            self.__connection_lost_callback(exc)
Exemplo n.º 3
0
 def _reconnect(self):
     """
     Set up Mongo connection.
     """
     loop = self._loop or asyncio.get_event_loop()
     while True:
         try:
             logger.log(
                 logging.INFO,
                 'Connecting to mongo at {host}:{port}'.format(
                     host=self.host, port=self.port))
             yield from loop.create_connection(lambda: self.protocol,
                                               self.host, self.port)
             self._reset_retry_interval()
             for name, auth in self._authenticators.items():
                 yield from auth.authenticate(Database(self.protocol, name))
                 logger.log(
                     logging.INFO,
                     'Authenticated to database {name}'.format(name=name))
             return
         except OSError:
             # Sleep and try again
             self._increase_retry_interval()
             interval = self._get_retry_interval()
             logger.log(
                 logging.INFO,
                 'Connecting to mongo failed. Retrying in %i seconds' %
                 interval)
             yield from asyncio.sleep(interval)
Exemplo n.º 4
0
 def _reconnect(self):
     """
     Set up Mongo connection.
     """
     loop = self._loop or asyncio.get_event_loop()
     while True:
         try:
             logger.log(logging.INFO, 'Connecting to mongo at {host}:{port}'.format(host=self.host, port=self.port))
             yield from loop.create_connection(lambda: self.protocol, self.host, self.port)
             self._reset_retry_interval()
             for name, auth in self._authenticators.items():
                 yield from auth.authenticate(Database(self.protocol, name))
                 logger.log(logging.INFO, 'Authenticated to database {name}'.format(name=name))
             return
         except OSError:
             # Sleep and try again
             self._increase_retry_interval()
             interval = self._get_retry_interval()
             logger.log(logging.INFO, 'Connecting to mongo failed. Retrying in %i seconds' % interval)
             yield from asyncio.sleep(interval)
Exemplo n.º 5
0
    def connection_made(self, transport):
        self.transport = transport

        self._is_connected = True
        logger.log(logging.INFO, 'Mongo connection made')
Exemplo n.º 6
0
    def connection_made(self, transport):
        self.transport = transport

        self._is_connected = True
        logger.log(logging.INFO, 'Mongo connection made')