You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/06/28 08:10:14 UTC

[GitHub] [spark] WeichenXu123 commented on a change in pull request #24986: [SPARK-28185][PYTHON][SQL] Closes the generator when Python UDFs stop early

WeichenXu123 commented on a change in pull request #24986: [SPARK-28185][PYTHON][SQL] Closes the generator when Python UDFs stop early
URL: https://github.com/apache/spark/pull/24986#discussion_r298493610
 
 

 ##########
 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:
   Sleep at last do not work. The sleep cmd cannot be interrupt (during sleep GeneratorExit cannot be raised)

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org