igrigorik/em-synchrony

Example redis call inside receive_data

Opened this issue · 1 comments

Could you provide an example how I should use synchrony when calling redis.set(key, value) inside EM's receive_data? I'm getting: synchrony.rb:81:in `yield': can't yield from root fiber (FiberError). How should I use a Fiber?

You would have to wrap all the code inside the receive_data function in a fiber context - e.g. use a fiber tool, or spawn a new fiber.

def receive_data(data)
  Fiber.new {...}.resume
end