From ca9edb27980cec4e9010563b294ee373b5c1db45 Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Tue, 26 Sep 2023 00:02:44 -0700 Subject: [PATCH] await all --- datastore/threads/asyncsemaphore.nim | 2 +- datastore/threads/threadproxyds.nim | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/datastore/threads/asyncsemaphore.nim b/datastore/threads/asyncsemaphore.nim index 1735460..b561882 100644 --- a/datastore/threads/asyncsemaphore.nim +++ b/datastore/threads/asyncsemaphore.nim @@ -29,7 +29,7 @@ func new*(_: type AsyncSemaphore, size: int): AsyncSemaphore = proc `count`*(s: AsyncSemaphore): int = s.count -proc waitAll*(s: AsyncSemaphore) {.async.} = +proc closeAll*(s: AsyncSemaphore) {.async.} = s.exit = true await allFutures(s.queue) diff --git a/datastore/threads/threadproxyds.nim b/datastore/threads/threadproxyds.nim index c0fc8a0..35237bc 100644 --- a/datastore/threads/threadproxyds.nim +++ b/datastore/threads/threadproxyds.nim @@ -209,8 +209,10 @@ method get*(self: ThreadDatastore, self.tp.spawn getTask(addr ctx, ds, key) method close*(self: ThreadDatastore): Future[?!void] {.async.} = - - await self.ds.close() + await self.semaphore.closeAll() + case self.backend.kind: + of Sqlite: + self.backend.sql.close() method query*(