如果需要多次与Apache Arrow Flight Server通信,则需要在每个请求之间重置FlightClient。这可以通过在确保所有请求已完成之后调用关闭方法来实现。以下是一个示例,其中一个请求处理函数被反复调用,且每次调用之间都重置了FlightClient:
import pyarrow.flight as flight
def process_request(request):
client = flight.FlightClient.connect('grpc://localhost:8080')
# process request using FlightClient
flight_service = client.do_action(request)
# reset client to ensure new connection is established
client.shutdown()