redis
redis copied to clipboard
How to get rid of Error: 'spawn' takes a GC safe call expression with the redis client
@Araq
This doesn't work:
import os, times, posix, logging, redis, threadpool
{.experimental.}
var running = true
proc proc_spawned() =
let redis_con = redis.open()
defer: redis_con.quit
while running == true:
echo("bRPop")
discard redis_con.bRPop("test", 1000)
os.sleep(1000)
spawn proc_spawned()
The problem i identified, happens with Redis.bRPop proc, but doesn't happen with Redis.rPop proc.
proc bRPop*(r: Redis, keys: varargs[string], timeout: int): RedisList =
## Remove and get the *last* element in a list, or block until one
## is available.
var args: seq[string] = @[]
for i in items(keys): args.add(i)
args.add($timeout)
r.sendCommand("BRPOP", args)
return r.readArray()