nim-lang / redis

Official redis wrapper for Nim.
Other
128 stars 35 forks source link

Calling `subscribe` breaks `quit` #34

Open arkanoid87 opened 2 years ago

arkanoid87 commented 2 years ago

Not sure how to title this, not even sure is it's a nim issue, async issue or redis lib issue, but the behaviour is that just by adding await redisClient.subscribe("whatever") you can make your code raise runtime exception.

import redis, asyncdispatch

proc asyncTest1() {.async.} =
    # A, B ... Error: unhandled exception: No handles or timers registered in dispatcher. [ValueError]
    echo "A"
    let redisClient = await openAsync()
    await redisClient.subscribe("command")
    echo "B"
    await redisClient.quit()
    echo "C" # never reached

proc asyncTest2() {.async.} =
    # runs OK: prints A B C
    echo "A"
    let redisClient = await openAsync()
    echo "B"
    await redisClient.quit()
    echo "C"

waitFor asyncTest1()