title: Unable to understand error "SparkListenerBus has already stopped! Dropping event ..."
body: <h2>The issue</h2>
  
  <p>I'd like to know if anyone has a magic method to avoid such messages in Spark logs:</p>
  
  <pre><code>2015-08-30 19:30:44 ERROR LiveListenerBus:75 - SparkListenerBus has already
  stopped! Dropping event SparkListenerExecutorMetricsUpdate(41,WrappedArray())
  </code></pre>
  
  <p>After further investigations, I understand that <code>LiveListenerBus</code> extends <code>AsynchronousListenerBus</code>. And thus, at some point, <code>.stop()</code> method is called. Then, messages that might be sent/received will be dropped and remain unprocessed. Basically, some <code>SparkListenerExecutorMetricsUpdate</code> messages are unfortunately not received yet, and once they are, they become dropped to nowhere.</p>
  
  <p>This doesn't look critical since <code>SparkListenerExecutorMetricsUpdate</code> just correspond to <em>Periodic updates from executors.</em> </p>
  
  <p>What is embarrassing is that I absolutely don't understand why this happens and nothings refers to this issue. Note that this is totally non-deterministic and I can't reproduce this, probably due to the asynchronous nature and my lack of understand on how/when <code>stop()</code> is supposed to be called.</p>
  
  <h2>About the running code</h2>
  
  <p>A tight sample:</p>
  
  <pre><code>val sc = new SparkContext(sparkConf)
  val metricsMap = Metrics.values.toSeq.map(
      v =&gt; v -&gt; sc.accumulator(0, v.toString)
  ).toMap
  val outFiles = sc.textFile(outPaths)
  </code></pre>
  
  <p>And there's no other reference to <code>sc</code> or a <code>SparkContent</code> instance.</p>