예제 #1
0
    def execute_vtctl_command(self,
                              args,
                              action_timeout=30.0,
                              lock_timeout=5.0):
        req = vtctldata_pb2.ExecuteVtctlCommandRequest(
            args=args,
            action_timeout=long(action_timeout * 1e9),
            lock_timeout=long(lock_timeout * 1e9))
        with self.stub as stub:
            it = stub.ExecuteVtctlCommand(req, action_timeout)
            for response in it:
                t = datetime.datetime.utcfromtimestamp(
                    response.event.time.seconds)
                try:
                    yield vtctl_client.Event(t, response.event.level,
                                             response.event.file,
                                             response.event.line,
                                             response.event.value)
                except GeneratorExit:
                    # if the loop is interrupted for any reason, we need to
                    # cancel the iterator, so we close the RPC connection,
                    # and the with __exit__ statement is executed.

                    # FIXME(alainjobart) this is flaky. It sometimes doesn't stop
                    # the iterator, and we don't get out of the 'with'.
                    # Sending a Ctrl-C to the process then works for some reason.
                    it.cancel()
                    break
예제 #2
0
 def execute_vtctl_command(self, args, action_timeout=30.0):
     req = vtctldata_pb2.ExecuteVtctlCommandRequest(
         args=args, action_timeout=long(action_timeout * 1e9))
     it = self.stub.ExecuteVtctlCommand(req, action_timeout)
     for response in it:
         t = datetime.datetime.utcfromtimestamp(response.event.time.seconds)
         yield vtctl_client.Event(t, response.event.level,
                                  response.event.file, response.event.line,
                                  response.event.value)