Matthew-DWM commented on code in PR #9364:
URL: https://github.com/apache/texera/pull/9364#discussion_r4555865358


##########
amber/src/main/scala/org/apache/texera/amber/engine/architecture/pythonworker/PythonWorkflowWorker.scala:
##########
@@ -262,14 +337,35 @@ class PythonWorkflowWorker(
       workerConfig.largeBinaryBaseUri
     )
 
-    pythonServerProcess = Process(
+    // Python writes straight to this JVM's stdout and stderr, with no copying 
threads in between:
+    // its exit is then known when the process ends, even if a child it 
started (a UDF's
+    // subprocess, for example) still holds those streams open.
+    pythonServerProcess = new ProcessBuilder(
       Seq(
         pythonBin,
         "-u",
         udfEntryScriptPath,
         PythonWorkflowWorker.encodeStartupConfig(startupConfig)
-      )
-    ).run(BasicIO.standard(false))
+      ).asJava
+    ).redirectOutput(ProcessBuilder.Redirect.INHERIT)
+      .redirectError(ProcessBuilder.Redirect.INHERIT)
+      .start()
+    pythonServerProcess.getOutputStream.close() // the worker reads no input
+    watchPythonProcess()
+  }
+
+  /** Reports an exit of the Python process that this actor did not cause. */
+  private def watchPythonProcess(): Unit = {
+    val process = pythonServerProcess
+    val watcher = new Thread(
+      () => {
+        val code = process.waitFor()

Review Comment:
   Done in b2cc844fc: the exit watcher now catches `InterruptedException` and 
exits quietly.



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