Github user JoshRosen commented on a diff in the pull request:
https://github.com/apache/spark/pull/4923#discussion_r26011596
--- Diff: core/src/main/scala/org/apache/spark/api/python/PythonRDD.scala
---
@@ -575,15 +583,32 @@ private[spark] object PythonRDD extends Logging {
dataOut.write(bytes)
}
- def writeToFile[T](items: java.util.Iterator[T], filename: String) {
- import scala.collection.JavaConverters._
- writeToFile(items.asScala, filename)
- }
+ private def serveIterator[T](items: Iterator[T]): Int = {
+ val serverSocket = new ServerSocket(0, 1)
+ serverSocket.setReuseAddress(true)
+ serverSocket.setSoTimeout(3000)
+
+ new Thread("serve iterator") {
+ setDaemon(true)
+ override def run() {
+ try {
+ val sock = serverSocket.accept()
+ val out = new DataOutputStream(new
BufferedOutputStream(sock.getOutputStream))
+ try {
+ writeIteratorToStream(items, out)
+ } finally {
+ out.close()
+ }
+ } catch {
+ case NonFatal(e) =>
+ logError(s"Error while sending iterator: $e")
--- End diff --
If we change this to
```
logError("Error while sending iterator", e)
```
then the full stacktrace will be printed as part of the log message.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]