Skip to content

Commit

Permalink
Cancel the worker scope LAST, and log better.
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rken committed Dec 2, 2023
1 parent b96668b commit 60fc360
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,18 @@ class SchedulerWorker @AssistedInject constructor(
} finally {
try {
schedulerNotifications.cancel(scheduleId)
workerScope.cancel("Worker finished (withError?=$finishedWithError).")
schedulerManager.reschedule(scheduleId)
} catch (e: Exception) {
log(TAG, ERROR) { "Failed to clean up after scheduled work (error=$finishedWithError): ${e.asLog()}" }
log(
TAG,
ERROR
) { "Failed to clean up notifications and reschedule (error=$finishedWithError): ${e.asLog()}" }
}

try {
workerScope.cancel("Worker finished (withError?=$finishedWithError).")
} catch (e: Exception) {
log(TAG, ERROR) { "Failed to cancel worker scope (error=$finishedWithError): ${e.asLog()}" }
}
}

Expand Down

0 comments on commit 60fc360

Please sign in to comment.