gaogaotiantian commented on code in PR #55201:
URL: https://github.com/apache/spark/pull/55201#discussion_r3054034302


##########
python/pyspark/sql/connect/streaming/worker/foreach_batch_worker.py:
##########
@@ -100,4 +100,7 @@ def process(df_id, batch_id):  # type: 
ignore[no-untyped-def]
     sock.settimeout(None)
     write_int(os.getpid(), sock_file)
     sock_file.flush()
-    main(sock_file, sock_file)
+    try:
+        main(sock_file, sock_file)
+    finally:
+        sock_file.close()

Review Comment:
   The `with` statement requires implementation for the `context`. Basically 
you need to implement something to define what should be done for start/end 
phase - that's what's done in master. In this case, we want to keep the fix 
clean and clear. Having the `sock_file` closed after main is what we really 
need.
   
   Python provided the native context for `socket.makefile`, but we got our 
`sock_file` from our own implementation `local_connect_and_auth(conn_info, 
auth_secret)`, so we need to close it explicitly.



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