Github user zsxwing commented on a diff in the pull request:
https://github.com/apache/spark/pull/5280#discussion_r27453086
--- Diff: core/src/main/scala/org/apache/spark/util/EventLoop.scala ---
@@ -76,9 +76,21 @@ private[spark] abstract class EventLoop[E](name: String)
extends Logging {
def stop(): Unit = {
if (stopped.compareAndSet(false, true)) {
eventThread.interrupt()
- eventThread.join()
- // Call onStop after the event thread exits to make sure onReceive
happens before onStop
- onStop()
+ var onStopCalled = false
+ try {
+ eventThread.join()
+ // Call onStop after the event thread exits to make sure onReceive
happens before onStop
+ onStopCalled = true
+ onStop()
+ } catch {
+ case ie: InterruptedException =>
+ Thread.currentThread().interrupt()
+ if (!onStopCalled) {
+ // ie is thrown from `eventThread.join()`. Otherwise, we
should not call `onStop` since
--- End diff --
If the current thread is eventThread, then eventThread.interrupt() set the
interrupt flag. So `join` will throw `InterruptedException`.
---
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]