From 44b776ef32413febcf0e140cb5d839a798e35e3d Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Thu, 7 Sep 2023 16:00:02 +0200 Subject: [PATCH] Wait to write metrics --- Sources/App/configure.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sources/App/configure.swift b/Sources/App/configure.swift index 374012c..1ee1cab 100755 --- a/Sources/App/configure.swift +++ b/Sources/App/configure.swift @@ -118,10 +118,13 @@ private func migrateMetric(_ id: String, containing type: T.Type, in folder: // TODO: Write values back to disk let observer = MetricObserver(logFileFolder: folder, logMetricId: "sesame.migration") let metric: Metric = observer.addMetric(id: id) + private let semaphore = DispatchSemaphore(value: 0) Task { try await metric.update(all) print("Saved all values for metric \(id)") + semaphore.signal() } + semaphore.wait() print("Finished metric \(id)") }