rangadi commented on code in PR #46125:
URL: https://github.com/apache/spark/pull/46125#discussion_r1575192686


##########
core/src/main/scala/org/apache/spark/api/python/StreamingPythonRunner.scala:
##########
@@ -91,6 +91,11 @@ private[spark] class StreamingPythonRunner(
       new 
BufferedInputStream(pythonWorker.get.channel.socket().getInputStream, 
bufferSize))
 
     val resFromPython = dataIn.readInt()
+    if (resFromPython != 0) {
+      val errMessage = PythonWorkerUtils.readUTF(dataIn)
+      throw new RuntimeException(s"Runner initialization failed (returned 
$resFromPython). " +

Review Comment:
   Should be a PythonException? (comparing it with similar code in 
`StreamingForeachBatchHelper.scala`).
   Also, add 'Streaming' at the start of the message. 



##########
python/pyspark/sql/connect/streaming/worker/foreach_batch_worker.py:
##########
@@ -76,16 +71,20 @@ def process(df_id, batch_id):  # type: 
ignore[no-untyped-def]
         func(batch_df, batch_id)
         print(f"{log_name} Completed batch {batch_id} with DF id {df_id}")
 
-    while True:
-        df_ref_id = utf8_deserializer.loads(infile)
-        batch_id = read_long(infile)
-        # Handle errors inside Python worker. Write 0 to outfile if no errors 
and write -2 with
-        # traceback string if error occurs.
-        try:
+    try:
+        func = worker.read_command(pickle_ser, infile)
+        write_int(0, outfile)
+        outfile.flush()
+        while True:

Review Comment:
   minor: leave an empty line before this.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to