import asyncdispatch, asyncpg/asyncpg
const POOL_SIZE = 5
var pool = newPool(POOL_SIZE)
proc main() {.async.} =
var start: float
var connStr = "host=localhost port=5432 dbname=test user="
await pool.connect(connStr)
var futures = newSeq[Future[apgResult]]()
for i in 0..<10:
futures.add exec(pool, "SELECT $1, pg_sleep(1);", i)
var results = await all(futures)
for res in results:
for item in res[0].rows():
echo item, " "
waitFor main()
Starts 10 connections that sleep for 10 seconds. If pool size is less the number of connections strange error happens:
asyncpgtest.nim(18) asyncpgtest
asyncdispatch.nim(1654) waitFor
asyncdispatch.nim(1514) poll
asyncdispatch.nim(1233) runOnce
Error: unhandled exception: No handles or timers registered in dispatcher. [ValueError]
I think if connections are not available it should error out or wait some how. I think it just forgets to register no available connection case.
Nim Compiler Version 0.19.1 [MacOSX: amd64]
Compiled at 2018-10-22
Copyright (c) 2006-2018 by Andreas Rumpf
git hash: 16c3d4332fac56b275ca3c66dcf12573738bdc91
active boot switches: -d:release
Pool size of 10 works, pool size of 5 does not.
Starts 10 connections that sleep for 10 seconds. If pool size is less the number of connections strange error happens:
I think if connections are not available it should error out or wait some how. I think it just forgets to register no available connection case.