$queue = Queue.new $sq = SizedQueue.new(10) # in here i define aps which is a list of access point objects, i'll spare you the code, it works fine. Results are an array of these objects su_query_proc = proc do aps.each do |ap| $queue << Proc.new do puts "Querying #{ap.ipaddress} for information about subscribers." poll = Poller.new(Object.const_get("#{$vendor}#{$model}APDevice")) poll.community = config["snmp_read_community"] poll.host = ap.ipaddress poll.setup poll.device.su_db_dump(poll.device.su_items) puts "Finished dumping subscriber data." sleep 0.1 end end until $queue.empty? $sq << Thread.new(&$queue.pop) end end EventMachine::run do EventMachine::add_timer(30, su_query_proc) end =begin Errors out with this error: poller.rb:177:in `<<': stopping only thread (ThreadError) note: use sleep to stop forever from poller.rb:177 from /Library/Ruby/Gems/1.8/gems/eventmachine-0.9.0/lib/eventmachine.rb:1030:in `call' from /Library/Ruby/Gems/1.8/gems/eventmachine-0.9.0/lib/eventmachine.rb:1030:in `event_callback' from /Library/Ruby/Gems/1.8/gems/eventmachine-0.9.0/lib/eventmachine.rb:223:in `run_machine' from /Library/Ruby/Gems/1.8/gems/eventmachine-0.9.0/lib/eventmachine.rb:223:in `run' from poller.rb:186 line 177 is the $sq << Thread.new(&$queue.pop) line line 186 is the add_timer() line.