Github user viirya commented on a diff in the pull request: https://github.com/apache/spark/pull/16263#discussion_r92831404 --- Diff: python/pyspark/rdd.py --- @@ -2349,7 +2352,12 @@ def toLocalIterator(self): """ with SCCallSiteSync(self.context) as css: port = self.ctx._jvm.PythonRDD.toLocalIteratorAndServe(self._jrdd.rdd()) - return _load_from_socket(port, self._jrdd_deserializer) + # We set a timeout for connecting socket. The connection only begins when we start + # to consume the first element. If we do not begin to consume the returned iterator + # immediately, there will be a failure. + iter = _load_from_socket(port, self._jrdd_deserializer) --- End diff -- We still keep connection timeout. Eagerly evaluating of the first element is needed for it. Because it is going to connect the socket only if we begin to consume the iterator. Otherwise, the server socket in JVM side will be timeout.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org