示例#1
0
    def _get_controller(self):
        ''' get the controller, also sets the iteration count '''
        reconnect = self.host_changed

        if not reconnect:
            try:
                c = self.client.controller
                self.iteration = c.get_count()
            except Exception as e:
                logger.info(
                    'Error: no connection or connection closed: reconnecting')
                reconnect = True
                self.client = None

        if reconnect:
            self.host_changed = False
            try:
                if MultiprocessingClient.is_available((self.host, self.port)):
                    self.client = MultiprocessingClient(address=(self.host,
                                                                 self.port),
                                                        authkey=self.authkey)
                else:
                    return None
            except Exception as e:
                logger.info('Could not connect: check if solver is running')
                return None
            c = self.client.controller
            self.iteration = c.get_count()

        return self.client.controller
示例#2
0
 def _get_controller(self):
     ''' get the controller, also sets the iteration count '''
     reconnect = self.host_changed
     
     if not reconnect:
         try:
             c = self.client.controller
             self.iteration = c.get_count()
         except Exception as e:
             logger.info('Error: no connection or connection closed: reconnecting')
             reconnect = True
             self.client = None
     
     if reconnect:
         self.host_changed = False
         try:
             if MultiprocessingClient.is_available((self.host, self.port)):
                 self.client = MultiprocessingClient(address=(self.host, self.port),
                                                     authkey=self.authkey)
             else:
                 return None
         except Exception as e:
             logger.info('Could not connect: check if solver is running')
             return None
         c = self.client.controller
         self.iteration = c.get_count()
     
     return self.client.controller
示例#3
0
    def _get_controller(self):
        ''' get the controller, also sets the iteration count '''
        if not self.live_mode:
            return None

        reconnect = self.host_changed
        if not reconnect:
            try:
                c = self.client.controller
            except Exception as e:
                logger.info('Error: no connection or connection closed: '
                            'reconnecting: %s' % e)
                reconnect = True
                self.client = None
            else:
                try:
                    self.client.controller.get_count()
                except IOError:
                    self.client = None
                    reconnect = True

        if reconnect:
            self.host_changed = False
            try:
                if MultiprocessingClient.is_available((self.host, self.port)):
                    self.client = MultiprocessingClient(
                        address=(self.host, self.port),
                        authkey=self.authkey
                    )
                else:
                    logger.info(
                        'Could not connect: Multiprocessing Interface'
                        ' not available on %s:%s' % (self.host, self.port)
                    )
                    return None
            except Exception as e:
                logger.info('Could not connect: check if solver is '
                            'running:%s' % e)
                return None
            c = self.client.controller
            self.iteration = c.get_count()

        if self.client is None:
            return None
        else:
            return self.client.controller
示例#4
0
    def _get_controller(self):
        ''' get the controller, also sets the iteration count '''
        if self.n_files > -1:
            return None

        reconnect = self.host_changed
        if not reconnect:
            try:
                c = self.client.controller
            except Exception as e:
                logger.info('Error: no connection or connection closed: '\
                        'reconnecting: %s'%e)
                reconnect = True
                self.client = None
            else:
                try:
                    self.client.controller.get_count()
                except IOError:
                    self.client = None
                    reconnect = True

        if reconnect:
            self.host_changed = False
            try:
                if MultiprocessingClient.is_available((self.host, self.port)):
                    self.client = MultiprocessingClient(address=(self.host, self.port),
                                                        authkey=self.authkey)
                else:
                    logger.info('Could not connect: Multiprocessing Interface'\
                                ' not available on %s:%s'%(self.host,self.port))
                    return None
            except Exception as e:
                logger.info('Could not connect: check if solver is '\
                            'running:%s'%e)
                return None
            c = self.client.controller
            self.iteration = c.get_count()

        if self.client is None:
            return None
        else:
            return self.client.controller