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


##########
amber/src/main/scala/org/apache/texera/amber/engine/architecture/pythonworker/PythonProxyClient.scala:
##########
@@ -155,13 +154,35 @@ class PythonProxyClient(portNumberPromise: Promise[Int], 
val actorId: ActorVirtu
     schemaRoot.clear()
     writer.completed()
 
-    // for calculating sender credits - get back number of batches in Python 
worker queue
-    val ackMsgBuf: ArrowBuf = flightListener.poll(5, 
TimeUnit.SECONDS).getApplicationMetadata
+    finishPut(writer, flightListener)
+
+    flightListener.close()
+  }
+
+  /**
+    * Finishes a put: reads the Python queue size that Python returns for it, 
for sender
+    * credits, then the put's own status. Waits as long as it takes: a busy 
Python process (one
+    * holding the GIL in a long native call, for example) may answer late, and 
a dead one fails
+    * the call instead, which the worker reports along with the exit it 
observes on its own.
+    * A put that ends without its ack, or fails after it, ends the client with 
that error.
+    */
+  private def finishPut(
+      writer: FlightClient.ClientStreamListener,
+      flightListener: SyncPutListener
+  ): Unit = {
+    val ack = flightListener.read()
+    if (ack == null) {
+      throw new WorkflowRuntimeException(
+        s"Python worker ${actorId.name} completed a put without acknowledging 
it",
+        Some(actorId)
+      )
+    }
+    val ackMsgBuf: ArrowBuf = ack.getApplicationMetadata

Review Comment:
   Done in #9413: a put that ends without an ack, or whose ack carries no queue 
size, now fails with an error naming the worker, and `finishPut` closes the 
listener in a `finally` block.



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