From fab42945e8e5a1e9a8296f5e4bcbe476a6a5bbd6 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Sat, 30 Jul 2022 13:11:38 +0200 Subject: fix(web/runner): Gracefully exit on interrupt This change updates the web runner implementation to gracefully exit the current thread when interrupted. --- .../src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'opendc-web/opendc-web-runner') diff --git a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt index ccc7f03a..7e0133d0 100644 --- a/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt +++ b/opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt @@ -98,11 +98,6 @@ public class OpenDCRunner( override fun run() { try { while (true) { - // Check if anyone has interrupted the thread - if (Thread.interrupted()) { - throw InterruptedException() - } - val job = manager.findNext() if (job == null) { Thread.sleep(pollInterval.toMillis()) @@ -120,6 +115,8 @@ public class OpenDCRunner( pool.submit(JobAction(job)) } + } catch (_: InterruptedException) { + // Gracefully exit when the thread is interrupted } finally { workloadLoader.reset() -- cgit v1.2.3