Merge pull request #5225 from samvel1024/develop

Sleep the current thread when we need to retry background job shutdown
This commit is contained in:
eugene yokota 2019-11-06 10:33:51 -05:00 committed by GitHub
commit 08c7fd1b8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 0 deletions

View File

@ -421,6 +421,13 @@ private[sbt] class BackgroundThreadPool extends java.io.Closeable {
status = Stopped(Some(thread))
thread.interrupt()
case Stopped(threadOption) =>
// sleep to avoid consuming a lot of CPU
try {
Thread.sleep(10)
} catch {
case e: InterruptedException =>
Thread.currentThread().interrupt();
}
// try to interrupt again! woot!
threadOption.foreach(_.interrupt())
}