ruby - EventMachine -- Blocking main thread? -


i'm doing following in ruby eventmachine give me status output every 5 seconds:

def status_output   puts time.now.to_s   em::timer.new(5) { status_output } end  em::run   status_output end 

it's working fine, when i'm adding "work" eventmachine, there no status output longer:

em::run   status_output   10_000.times     em::defer(proc {       # ... processing data...     })   end end 

is indicator data processing blocking main thread? i'm using ruby mri 1.8.7 (i know, know), guess block affect threads (so guess explain that?)

by way, have checked data processing code, there nothing obvious blocking. common (not-so-obvious-)things might block?

edit:

i'm adding better example pointed out mudasobwa: (but i'm still not sure if isomorph i'm running)

require "rubygems" require "eventmachine"  def status_output   puts time.now.to_s   em::timer.new(1) { status_output } end  def process_data   500_000.times     rand(24 ** 24).to_s(36)   end   puts "#{time.now.to_s}: finished!" end  em::run   status_output   1000.times {     em::defer(proc {       process_data     })   } end  # output: # wed sep 04 18:08:58 +0400 2013 # wed sep 04 18:09:03 +0400 2013 # gap here # wed sep 04 18:09:04 +0400 2013 # wed sep 04 18:09:05 +0400 2013 # wed sep 04 18:09:06 +0400 2013 


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -