Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion core/src/main/scala/org/apache/spark/api/python/PythonRDD.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ private[spark] class PythonRDD[T: ClassTag](
override def compute(split: Partition, context: TaskContext): Iterator[Array[Byte]] = {
val startTime = System.currentTimeMillis
val env = SparkEnv.get
val worker = env.createPythonWorker(pythonExec, envVars.toMap)
val worker: Socket = env.createPythonWorker(pythonExec, envVars.toMap)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason to declare the type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the first time I read this code, I thought worker was some more interesting object. Just put the type to make it clear it's just a Socket.


// Ensure worker socket is closed on task completion. Closing sockets is idempotent.
context.addOnCompleteCallback(() =>
try {
worker.close()
} catch {
case e: Exception => logWarning("Failed to close worker socket", e)
}
)

@volatile var readerException: Exception = null

Expand Down