pitrou commented on code in PR #43766:
URL: https://github.com/apache/arrow/pull/43766#discussion_r1726548745


##########
cpp/src/arrow/filesystem/gcsfs_test.cc:
##########
@@ -99,60 +77,55 @@ class GcsTestbench : public ::testing::Environment {
         "Could not start GCS emulator."
         " Used the following list of python interpreter names:");
     for (const auto& interpreter : names) {
-      auto exe_path = bp::search_path(interpreter);
+      auto server_process = std::make_unique<util::Process>();
       error += " " + interpreter;
-      if (exe_path.empty()) {
+      auto status = server_process->SetExecutable(interpreter);
+      if (!status.ok()) {
         error += " (exe not found)";
         continue;
       }
 
-      bp::ipstream output;
-      server_process_ = bp::child(exe_path, "-m", "testbench", "--port", 
port_, group_,
-                                  bp::std_err > output);
-      // Wait for message: "* Restarting with"
-      auto testbench_is_running = [&output, this](bp::child& process) {
-        std::string line;
-        std::chrono::time_point<std::chrono::steady_clock> end =
-            std::chrono::steady_clock::now() + std::chrono::seconds(10);
-        while (server_process_.valid() && server_process_.running() &&
-               std::chrono::steady_clock::now() < end) {
-          if (output.peek() && std::getline(output, line)) {
-            std::cerr << line << std::endl;
-            if (line.find("* Restarting with") != std::string::npos) return 
true;
-          } else {
-            std::this_thread::sleep_for(std::chrono::milliseconds(20));
-          }
-        }
-        return false;
-      };
-
-      if (testbench_is_running(server_process_)) break;
-      error += " (failed to start)";
-      server_process_.terminate();
-      server_process_.wait();
+      status = server_process->SetArgs({"-m", "testbench", "--port", port_});
+      if (!status.ok()) {
+        error += " (failed to set args: ";
+        error += status.ToString();
+        error += ")";
+        continue;
+      }
+
+      status = server_process->SetReadyErrorMessage("* Restarting with");
+      if (!status.ok()) {
+        error += " (failed to set ready error message: ";
+        error += status.ToString();
+        error += ")";
+        continue;
+      }
+
+      status = server_process->Execute();
+      if (!status.ok()) {
+        error += " (failed to launch: ";
+        error += status.ToString();
+        error += ")";
+        continue;
+      }
+
+      server_process_ = std::move(server_process);
+      break;
     }
-    if (server_process_.valid() && server_process_.valid()) return;
+    if (server_process_) return;
     error_ = std::move(error);
   }
 
-  bool running() { return server_process_.running(); }
+  bool running() { return server_process_ && server_process_->IsRunning(); }
 
-  ~GcsTestbench() override {
-    // Brutal shutdown, kill the full process group because the GCS testbench 
may launch
-    // additional children.
-    group_.terminate();
-    if (server_process_.valid()) {
-      server_process_.wait();
-    }
-  }
+  ~GcsTestbench() override { server_process_ = nullptr; }

Review Comment:
   Ah, too bad. We'll have to do without it, then.



-- 
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