mengxr commented on a change in pull request #24986: [SPARK-28185][ML][SQL] 
Trigger pandas iterator UDF closing stuff when iterator stop early
URL: https://github.com/apache/spark/pull/24986#discussion_r298194968
 
 

 ##########
 File path: python/pyspark/sql/tests/test_pandas_udf_scalar.py
 ##########
 @@ -850,6 +850,36 @@ def test_close(batch_iter):
             with self.assertRaisesRegexp(Exception, "reached finally block"):
                 self.spark.range(1).select(test_close(col("id"))).collect()
 
+    def test_scalar_iter_udf_close_early(self):
+        tmp_dir = tempfile.mkdtemp()
+
+        @pandas_udf('int', PandasUDFType.SCALAR_ITER)
+        def test_close(batch_iter):
+            generator_exit_caught = False
+            try:
+                for batch in batch_iter:
+                    yield batch
+                    time.sleep(0.5)
 
 Review comment:
   Do not put a plain sleep here. Sleep after all just don't let the generator 
exit.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to