diff --git a/GRDB/Core/DatabasePool.swift b/GRDB/Core/DatabasePool.swift index a9bf1e718..1cc88fcde 100644 --- a/GRDB/Core/DatabasePool.swift +++ b/GRDB/Core/DatabasePool.swift @@ -424,29 +424,10 @@ extension DatabasePool: DatabaseReader { throw DatabaseError.connectionIsClosed() } - let dbAccess = CancellableDatabaseAccess() - return try await dbAccess.withCancellableContinuation { continuation in - readerPool.asyncGet { result in - do { - let (reader, releaseReader) = try result.get() - // Second async jump because that's how `Pool.async` has to be used. - reader.async { db in - defer { - releaseReader(.reuse) - } - do { - let result = try dbAccess.inDatabase(db) { - try db.clearSchemaCacheIfNeeded() - return try value(db) - } - continuation.resume(returning: result) - } catch { - continuation.resume(throwing: error) - } - } - } catch { - continuation.resume(throwing: error) - } + return try await readerPool.get { reader in + try await reader.execute { db in + try db.clearSchemaCacheIfNeeded() + return try value(db) } } }