lidavidm commented on a change in pull request #12465:
URL: https://github.com/apache/arrow/pull/12465#discussion_r816762541



##########
File path: cpp/src/arrow/flight/client.cc
##########
@@ -1399,21 +1328,41 @@ Status FlightClient::DoPut(const FlightCallOptions& 
options,
                            std::unique_ptr<FlightStreamWriter>* stream,
                            std::unique_ptr<FlightMetadataReader>* reader) {
   RETURN_NOT_OK(CheckOpen());
-  return impl_->DoPut(options, descriptor, schema, stream, reader);
+  std::unique_ptr<internal::ClientDataStream> remote_stream;
+  RETURN_NOT_OK(impl_->DoPut(options, &remote_stream));
+  std::shared_ptr<internal::ClientDataStream> shared_stream = 
std::move(remote_stream);
+  *reader =
+      std::unique_ptr<FlightMetadataReader>(new 
ClientMetadataReader(shared_stream));
+  *stream = std::unique_ptr<FlightStreamWriter>(
+      new ClientStreamWriter(std::move(shared_stream), options.write_options,
+                             write_size_limit_bytes_, descriptor));
+  RETURN_NOT_OK((*stream)->Begin(schema, options.write_options));
+  return Status::OK();
 }
 
 Status FlightClient::DoExchange(const FlightCallOptions& options,
                                 const FlightDescriptor& descriptor,
                                 std::unique_ptr<FlightStreamWriter>* writer,
                                 std::unique_ptr<FlightStreamReader>* reader) {
   RETURN_NOT_OK(CheckOpen());
-  return impl_->DoExchange(options, descriptor, writer, reader);
+  std::unique_ptr<internal::ClientDataStream> remote_stream;
+  RETURN_NOT_OK(impl_->DoExchange(options, &remote_stream));
+  std::shared_ptr<internal::ClientDataStream> shared_stream = 
std::move(remote_stream);
+  *reader = std::unique_ptr<FlightStreamReader>(
+      new ClientStreamReader(shared_stream, options.read_options, 
options.stop_token));
+  auto stream_writer = std::unique_ptr<ClientStreamWriter>(
+      new ClientStreamWriter(std::move(shared_stream), options.write_options,
+                             write_size_limit_bytes_, descriptor));
+  RETURN_NOT_OK(stream_writer->Begin());
+  *writer = std::move(stream_writer);
+  return Status::OK();
 }
 
 Status FlightClient::Close() {
-  // gRPC doesn't offer an explicit shutdown
-  impl_.reset(nullptr);
-  // TODO(ARROW-15473): if we track ongoing RPCs, we can cancel them first
+  if (impl_) {
+    RETURN_NOT_OK(impl_->Close());
+    impl_.reset(nullptr);

Review comment:
       Hmm, oddly enough that just moves the hang to 
`GrpcDataTest.TestDoGetLargeBatch`. The issue is still the same: gRPC has an 
internal thread pool with one thread left, blocked on epoll_wait with a 10 
second timeout. It's hard to tell what exactly created that thread, though…




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to