Skip to content

"cannot yield from root fiber" when used with EM.synchrony #22

@JohnMerlino1

Description

@JohnMerlino1

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions