Skip to content
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ private[spark] class PythonRDD(

context.addTaskCompletionListener { context =>
writerThread.shutdownOnTaskCompletion()
writerThread.join()
if (!reuse_worker || !released) {
try {
worker.close()
Expand Down Expand Up @@ -249,13 +248,17 @@ private[spark] class PythonRDD(
} catch {
case e: Exception if context.isCompleted || context.isInterrupted =>
logDebug("Exception thrown after task completion (likely due to cleanup)", e)
Utils.tryLog(worker.shutdownOutput())
if (!worker.isClosed) {
Utils.tryLog(worker.shutdownOutput())
}

case e: Exception =>
// We must avoid throwing exceptions here, because the thread uncaught exception handler
// will kill the whole executor (see org.apache.spark.executor.Executor).
_exception = e
Utils.tryLog(worker.shutdownOutput())
if (!worker.isClosed) {
Utils.tryLog(worker.shutdownOutput())
}
} finally {
// Release memory used by this thread for shuffles
env.shuffleMemoryManager.releaseMemoryForThisThread()
Expand Down
5 changes: 4 additions & 1 deletion python/pyspark/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ def worker(sock):
except SystemExit as exc:
exit_code = compute_real_exit_code(exc.code)
finally:
outfile.flush()
try:
outfile.flush()
except Exception:
pass
return exit_code


Expand Down
5 changes: 5 additions & 0 deletions python/pyspark/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,11 @@ def test_multiple_python_java_RDD_conversions(self):
converted_rdd = RDD(data_python_rdd, self.sc)
self.assertEqual(2, converted_rdd.count())

# Regression test for SPARK-6294
def test_take_on_jrdd(self):
rdd = self.sc.parallelize(range(1 << 20)).map(lambda x: str(x))
rdd._jrdd.first()


class ProfilerTests(PySparkTestCase):

Expand Down