Exemplo n.º 1
0
    def WaitingForDuplex(self, request, context):
        logging.debug("Server RPC: WaitingForDuplex from '%s' (api v2)" %
                      request.readable_name)

        max_tries = 20
        i = 0

        # try for ~5 seconds (the caller aborts at 4)
        while i < max_tries:
            response = False

            try:
                remote = self.remote_machines[request.id]
                response = (remote.status in (RemoteStatus.AWAITING_DUPLEX,
                                              RemoteStatus.ONLINE))
            except KeyError:
                pass

            if response:
                break
            else:
                i += 1
                if i == max_tries:
                    context.abort(
                        code=grpc.StatusCode.DEADLINE_EXCEEDED,
                        details=
                        'Server timed out while waiting for his corresponding remote to connect back to you.'
                    )
                    return
                time.sleep(.25)

        return warp_pb2.HaveDuplex(response=response)
Exemplo n.º 2
0
    def CheckDuplexConnection(self, request, context):
        response = False

        try:
            remote = self.remote_machines[request.id]
            response = (remote.status
                        in (RemoteStatus.AWAITING_DUPLEX, RemoteStatus.ONLINE))
        except KeyError:
            pass

        return warp_pb2.HaveDuplex(response=response)
Exemplo n.º 3
0
    def CheckDuplexConnection(self, request, context):
        logging.debug("Server RPC: CheckDuplexConnection from '%s'" %
                      request.readable_name)
        response = False

        try:
            remote = self.remote_machines[request.id]
            response = (remote.status
                        in (RemoteStatus.AWAITING_DUPLEX, RemoteStatus.ONLINE))
        except KeyError:
            pass

        return warp_pb2.HaveDuplex(response=response)