Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get rid of Error: 'spawn' takes a GC safe call expression with the redis client #2

Open
ray-delossantos opened this issue Dec 9, 2015 · 0 comments

Comments

@ray-delossantos
Copy link

@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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant