diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-07-30 13:11:38 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2022-08-03 11:33:44 +0200 |
| commit | fab42945e8e5a1e9a8296f5e4bcbe476a6a5bbd6 (patch) | |
| tree | c592a3f5c36a719ab94b8e42c0211781bcaeb4fb /opendc-web/opendc-web-runner/src/main | |
| parent | ebc6cdd08a0d8dac045305839421b726ae5c91b3 (diff) | |
fix(web/runner): Gracefully exit on interrupt
This change updates the web runner implementation to gracefully exit the
current thread when interrupted.
Diffstat (limited to 'opendc-web/opendc-web-runner/src/main')
| -rw-r--r-- | opendc-web/opendc-web-runner/src/main/kotlin/org/opendc/web/runner/OpenDCRunner.kt | 7 |
1 files changed, 2 insertions, 5 deletions
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() |
