ruby find proxy method with thread


SUBMITTED BY: Guest

DATE: Sept. 28, 2014, 7:59 p.m.

FORMAT: Ruby

SIZE: 702 Bytes

HITS: 995

  1. def get_proxy
  2. good = []
  3. threads = []
  4. ls_prx = Proxy.new
  5. proxy_ls = ls_prx.get_all
  6. proxy_ls.each do |test_prx|
  7. proxy_thread = Thread.new do
  8. res = Proxy.new
  9. if
  10. res.test_active(test_prx) && !@used_proxy.include?(test_prx)
  11. then
  12. good << test_prx
  13. puts "#{test_prx} good"
  14. else
  15. #puts "#{test_prx} not good"
  16. end
  17. threads << proxy_thread
  18. end
  19. end
  20. threads.each do |thread|
  21. thread.join
  22. end
  23. puts "#{good}"
  24. return good.first
  25. end

comments powered by Disqus