em-imap
em-imap copied to clipboard
"cannot yield from root fiber" when used with EM.synchrony
I am trying to work with an ActiveRecord object on the callback but I get the error "cannot yield from root fiber":
EM.synchrony do
User.all.each do |user|
client = EM::IMAP.new('imap.gmail.com',993,true)
client.connect.bind! do
delegate.login(user.email, user.password)
end.bind! do
delegate.select('INBOX')
end.bind! do
delegate.search('1:20')
end.bind! do |ids|
delegate.fetch(ids, "(UID ENVELOPE BODY[TEXT])")
end.callback do |msgs|
user.update_attributes body: msgs.attr["BODY[TEXT]"] # Error here: cannot yield from root fiber
end
end
end
Why does this happen and how can I resolve it?
Hi @JohnMerlino1, I'm not sure exactly. Unfortunately I haven't used this library in over 4 years, so can't immediately think of anything.
Please let me know if anything comes up.
P.S. What are you trying to build? Looks like fun!
@ConradIrwin I am just trying to understand how the fibers are working. I asked the question on stackoverflow: http://stackoverflow.com/questions/39670727/asynchronous-programming-with-fibers Perhaps you can offer some insights. Thanks.