withPool executes provided statement block in a try/finally to ensure the connection is released.
This commit is contained in:
parent
d4540a1de7
commit
9625ac6a5e
@ -93,5 +93,5 @@ proc release*(pool: DbConnPool, connId: int): void =
|
||||
|
||||
template withConn*(pool: DbConnPool, stmt: untyped): untyped =
|
||||
let (connId, conn {.inject.}) = take(pool)
|
||||
stmt
|
||||
release(pool, connId)
|
||||
try: stmt
|
||||
finally: release(pool, connId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user