Ejemplo n.º 1
0
    def _synchronize_ready(self, connection):
        # TODO set timeout and retry count
        if self.peer is None:
            raise NoPeerError

        others = list(self.core.launch_deps.values())
        self.logger.info('waiting for other peers %s: ', str(others))
        msg = cmsg.fill_and_pack(types.PEERS_READY_QUERY, sender=self.peer_id,
                                 deps=others)

        ready = False
        while not ready:
            reply = self.__query(connection, msg, types.PEERS_READY_QUERY)
            # print 'got!', reply, cmsg.unpack_msg(reply.type, reply.message)
            if reply is None:
                # TODO sth bad happened, raise exception?

                continue
            if reply.type == types.READY_STATUS:
                rmsg = cmsg.unpack_msg(reply.type, reply.message)

                ready = rmsg.peers_ready
            if not ready:
                time.sleep(2)
        self.logger.info("Dependencies are ready, I can start working")
Ejemplo n.º 2
0
    def _synchronize_ready(self, connection):
        #TODO set timeout and retry count
        if self.peer is None:
            raise NoPeerError

        others = self.core.launch_deps.values()
        self.logger.info('waiting for other peers %s: ', str(others))
        msg = cmsg.fill_and_pack(types.PEERS_READY_QUERY,
                                 sender=self.peer_id,
                                 deps=others)

        ready = False
        while not ready:
            reply = self.__query(connection, msg, types.PEERS_READY_QUERY)
            # print 'got!', reply, cmsg.unpack_msg(reply.type, reply.message)
            if reply is None:
                #TODO sth bad happened, raise exception?

                continue
            if reply.type == types.READY_STATUS:
                rmsg = cmsg.unpack_msg(reply.type, reply.message)

                ready = rmsg.peers_ready
            if not ready:
                time.sleep(2)
        self.logger.info("Dependencies are ready, I can start working")
Ejemplo n.º 3
0
    def send_peer_ready(self, connection):
        if self.peer is None:
            raise NoPeerError
        self.logger.info('sending ready signal.')
        mtype = types.PEER_READY
        msg = cmsg.fill_and_pack(mtype, peer_id=self.peer_id)

        self.__query(connection, msg, mtype)

        self._synchronize_ready(connection)
Ejemplo n.º 4
0
    def send_peer_ready(self, connection):
        if self.peer is None:
            raise NoPeerError
        self.logger.info('sending ready signal.')
        mtype = types.PEER_READY
        msg = cmsg.fill_and_pack(mtype, peer_id=self.peer_id)

        reply = self.__query(connection, msg, mtype)

        self._synchronize_ready(connection)