0

A very simple case where I get the root Fiber error.

require 'em-synchrony'
require 'em-synchrony/em-http'

urls = %w{http://www.google.com http://www.google.com http://www.google.com http://www.google.com http://www.google.com http://www.google.com}
EM.synchrony do

  EM::Synchrony::Iterator.new(urls, 2).each(
      proc { |url, iter|

        EM::HttpRequest.new(url).get
        iter.next
      }
  )
end

I can use async here, but not a sync http request.

keaplogik
  • 2,369
  • 2
  • 25
  • 26
  • To me it seems too complicated. I would not call `run_em_normalization` recursively because I am not sure what happens when you attempt to start EM loop from inside an existing EM loop (that is what `EM.synchrony` is - an event loop with some fibers code added). – akonsu Jun 25 '13 at 15:28
  • I simplified the question. – keaplogik Jun 25 '13 at 17:09

1 Answers1

2

Looks like if I'm going to use the sync get request I should be using FiberIterator.

require 'em-synchrony'
require 'em-synchrony/em-http'
require "em-synchrony/fiber_iterator"

urls = %w{http://www.google.com http://www.google.com http://www.google.com http://www.google.com http://www.google.com http://www.google.com}
EM.synchrony do


  EM::Synchrony::FiberIterator.new(urls, 2).each(
      proc { |url|

        EM::HttpRequest.new(url).get

      }
  )
end
keaplogik
  • 2,369
  • 2
  • 25
  • 26