environment/lib/python2.7/site-packages/IPython/parallel/controller/hub.py
def register_engine(self, reg, msg):
        """Register a new engine."""
        content = msg['content']
        try:
            queue = cast_bytes(content['queue'])
        except KeyError:
            self.log.error("registration::queue not specified", exc_info=True)
            return
        heart = content.get('heartbeat', None)
        if heart:
            heart = cast_bytes(heart)
        """register a new engine, and create the socket(s) necessary"""
        eid = self._next_id
        # print (eid, queue, reg, heart)

        self.log.debug("registration::register_engine(%i, %r, %r, %r)", eid, queue, reg, heart)

        content = dict(id=eid,status='ok')
        content.update(self.engine_info)
        # check if requesting available IDs:
        if queue in self.by_ident:
            try:
                raise KeyError("queue_id %r in use" % queue)
            except:
                content = error.wrap_exception()
                self.log.error("queue_id %r in use", queue, exc_info=True)
        elif heart in self.hearts: # need to check unique hearts?
            try:
                raise KeyError("heart_id %r in use" % heart)
            except:
                self.log.error("heart_id %r in use", heart, exc_info=True)
                content = error.wrap_exception()
        else:
            for h, pack in self.incoming_registrations.iteritems():
                if heart == h:
                    try:
                        raise KeyError("heart_id %r in use" % heart)
                    except:
                        self.log.error("heart_id %r in use", heart, exc_info=True)
                        content = error.wrap_exception()
                    break
                elif queue == pack[1]:
                    try:
                        raise KeyError("queue_id %r in use" % queue)
                    except:
                        self.log.error("queue_id %r in use", queue, exc_info=True)
                        content = error.wrap_exception()
                    break

        msg = self.session.send(self.query, "registration_reply",
                content=content,
                ident=reg)

        if content['status'] == 'ok':
            if heart in self.heartmonitor.hearts:
                # already beating
                self.incoming_registrations[heart] = (eid,queue,reg[0],None)
                self.finish_registration(heart)
            else:
                purge = lambda : self._purge_stalled_registration(heart)
                dc = ioloop.DelayedCallback(purge, self.registration_timeout, self.loop)
                dc.start()
                self.incoming_registrations[heart] = (eid,queue,reg[0],dc)
        else:
            self.log.error("registration::registration %i failed: %r", eid, content['evalue'])
        return eid
def register_engine(self, reg, msg):
        content = msg['content']
        try:
            queue = cast_bytes(content['queue'])
        except KeyError:
            self.log.error("registration::queue not specified", exc_info=True)
            return
        heart = content.get('heartbeat', None)
        if heart:
            heart = cast_bytes(heart)
        """register a new engine, and create the socket(s) necessary"""
        eid = self._next_id
        # print (eid, queue, reg, heart)

        self.log.debug("registration::register_engine(%i, %r, %r, %r)", eid, queue, reg, heart)

        content = dict(id=eid,status='ok')
        content.update(self.engine_info)
        # check if requesting available IDs:
        if queue in self.by_ident:
            try:
                raise KeyError("queue_id %r in use" % queue)
            except:
                content = error.wrap_exception()
                self.log.error("queue_id %r in use", queue, exc_info=True)
        elif heart in self.hearts: # need to check unique hearts?
            try:
                raise KeyError("heart_id %r in use" % heart)
            except:
                self.log.error("heart_id %r in use", heart, exc_info=True)
                content = error.wrap_exception()
        else:
            for h, pack in self.incoming_registrations.iteritems():
                if heart == h:
                    try:
                        raise KeyError("heart_id %r in use" % heart)
                    except:
                        self.log.error("heart_id %r in use", heart, exc_info=True)
                        content = error.wrap_exception()
                    break
                elif queue == pack[1]:
                    try:
                        raise KeyError("queue_id %r in use" % queue)
                    except:
                        self.log.error("queue_id %r in use", queue, exc_info=True)
                        content = error.wrap_exception()
                    break

        msg = self.session.send(self.query, "registration_reply",
                content=content,
                ident=reg)

        if content['status'] == 'ok':
            if heart in self.heartmonitor.hearts:
                # already beating
                self.incoming_registrations[heart] = (eid,queue,reg[0],None)
                self.finish_registration(heart)
            else:
                purge = lambda : self._purge_stalled_registration(heart)
                dc = ioloop.DelayedCallback(purge, self.registration_timeout, self.loop)
                dc.start()
                self.incoming_registrations[heart] = (eid,queue,reg[0],dc)
        else:
            self.log.error("registration::registration %i failed: %r", eid, content['evalue'])
        return eid
def register_engine ( self , reg , msg ) : content = msg [ 'content' ] try : queue = cast_bytes ( content [ 'queue' ] ) except KeyError : self . log . error ( "registration::queue not specified" , exc_info = True ) return heart = content . get ( 'heartbeat' , None ) if heart : heart = cast_bytes ( heart ) """register a new engine, and create the socket(s) necessary""" eid = self . _next_id # print (eid, queue, reg, heart) self . log . debug ( "registration::register_engine(%i, %r, %r, %r)" , eid , queue , reg , heart ) content = dict ( id = eid , status = 'ok' ) content . update ( self . engine_info ) # check if requesting available IDs: if queue in self . by_ident : try : raise KeyError ( "queue_id %r in use" % queue ) except : content = error . wrap_exception ( ) self . log . error ( "queue_id %r in use" , queue , exc_info = True ) elif heart in self . hearts : # need to check unique hearts? try : raise KeyError ( "heart_id %r in use" % heart ) except : self . log . error ( "heart_id %r in use" , heart , exc_info = True ) content = error . wrap_exception ( ) else : for h , pack in self . incoming_registrations . iteritems ( ) : if heart == h : try : raise KeyError ( "heart_id %r in use" % heart ) except : self . log . error ( "heart_id %r in use" , heart , exc_info = True ) content = error . wrap_exception ( ) break elif queue == pack [ 1 ] : try : raise KeyError ( "queue_id %r in use" % queue ) except : self . log . error ( "queue_id %r in use" , queue , exc_info = True ) content = error . wrap_exception ( ) break msg = self . session . send ( self . query , "registration_reply" , content = content , ident = reg ) if content [ 'status' ] == 'ok' : if heart in self . heartmonitor . hearts : # already beating self . incoming_registrations [ heart ] = ( eid , queue , reg [ 0 ] , None ) self . finish_registration ( heart ) else : purge = lambda : self . _purge_stalled_registration ( heart ) dc = ioloop . DelayedCallback ( purge , self . registration_timeout , self . loop ) dc . start ( ) self . incoming_registrations [ heart ] = ( eid , queue , reg [ 0 ] , dc ) else : self . log . error ( "registration::registration %i failed: %r" , eid , content [ 'evalue' ] ) return eid
Register a new engine.
Register a new engine .