def connect(self): # type: () -> Iterable if hasattr(self, '_logging_stub'): del self._logging_stub # type: ignore[has-type] self._logging_stub = beam_fn_api_pb2_grpc.BeamFnLoggingStub( self._log_channel) return self._logging_stub.Logging(self._write_log_entries())
def __init__(self, log_service_descriptor): super(FnApiLogRecordHandler, self).__init__() self._log_channel = grpc.insecure_channel(log_service_descriptor.url) self._logging_stub = beam_fn_api_pb2_grpc.BeamFnLoggingStub( self._log_channel) self._log_entry_queue = queue.Queue() log_control_messages = self._logging_stub.Logging( self._write_log_entries()) self._reader = threading.Thread( target=lambda: self._read_log_control_messages(log_control_messages ), name='read_log_control_messages') self._reader.daemon = True self._reader.start()
def __init__(self, log_service_descriptor): super(FnApiLogRecordHandler, self).__init__() # Make sure the channel is ready to avoid [BEAM-4649] ch = grpc.insecure_channel(log_service_descriptor.url) grpc.channel_ready_future(ch).result(timeout=60) self._log_channel = grpc.intercept_channel(ch, WorkerIdInterceptor()) self._logging_stub = beam_fn_api_pb2_grpc.BeamFnLoggingStub( self._log_channel) self._log_entry_queue = queue.Queue() log_control_messages = self._logging_stub.Logging(self._write_log_entries()) self._reader = threading.Thread( target=lambda: self._read_log_control_messages(log_control_messages), name='read_log_control_messages') self._reader.daemon = True self._reader.start()
def connect(self): if hasattr(self, '_logging_stub'): del self._logging_stub self._logging_stub = beam_fn_api_pb2_grpc.BeamFnLoggingStub( self._log_channel) return self._logging_stub.Logging(self._write_log_entries())