Skip to content

Commit 19c144e

Browse files
committed
Prevent the call to SparkContext#stop() in the listener bus's thread
1 parent 37cff1b commit 19c144e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/src/main/scala/org/apache/spark/SparkContext.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,10 @@ class SparkContext(config: SparkConf) extends Logging with ExecutorAllocationCli
16941694

16951695
// Shut down the SparkContext.
16961696
def stop() {
1697+
if (AsynchronousListenerBus.withinListenerThread.value) {
1698+
throw new SparkException("Cannot stop SparkContext within listener thread of" +
1699+
" AsynchronousListenerBus")
1700+
}
16971701
// Use the stopping variable to ensure no contention for the stop scenario.
16981702
// Still track the stopped variable for use elsewhere in the code.
16991703
if (!stopped.compareAndSet(false, true)) {

0 commit comments

Comments
 (0)