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_r298193020
 
 

 ##########
 File path: python/pyspark/serializers.py
 ##########
 @@ -235,6 +237,12 @@ def dump_stream(self, iterator, stream):
                 if writer is None:
                     writer = pa.RecordBatchStreamWriter(stream, batch.schema)
                 writer.write_batch(batch)
+        except BaseException as be:
+            if isinstance(iterator, GeneratorType):
+                # if the iterator is a generator, it may include some code for
+                # closing resources.
+                iterator.close()
 
 Review comment:
   Should move it to where we call `dump_stream`, which is `process` in 
worker.py.

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