R
Rushi
I have a script doing some multi-threaded work. Every thread is a call
to an API making a simple post request. My problem is that the script
throws a Timeout:Error when i'm waiting for all my threads to join
<code>
/usr/lib/ruby/1.8/timeout.rb:60:in `rbuf_fill': execution expired
(Timeout::Error)
from test.rb:35:in `join'
from test.rb:35
from test.rb:34:in `each'
from test.rb:34
</code>
Here's my code - test.rb
<code>
amount = 60
@threads = []
1.upto(amount) { |i|
@threads << Thread.new do
puts "New Thread Created #{i}"
# This thread makes 10 post requests
1.upto(10) { |j|
puts "Thread #{i} Try #{j}"
# => DO post request using Net:HTTP
Net::HTTP.start("localhost", "80") do |http|
response = http.request_post("/test/mypost.php?get=value",
"a=b,c=d")
end
}
end
}
# Join all the threads we have created
@threads.each{ |thr|
thr.join # Timeout:ERror thrown here after approx 1.5 mins
}
</code>
Wrapping my thread.join call around Timeout::timeout (http://www.ruby-
doc.org/stdlib/libdoc/timeout/rdoc/classes/Timeout.html) didn't help
either.
Any suggestions how to make it *not* timeout so that I can finish
making all the API calls? I've tried hard but haven't been able to
find a solution
to an API making a simple post request. My problem is that the script
throws a Timeout:Error when i'm waiting for all my threads to join
<code>
/usr/lib/ruby/1.8/timeout.rb:60:in `rbuf_fill': execution expired
(Timeout::Error)
from test.rb:35:in `join'
from test.rb:35
from test.rb:34:in `each'
from test.rb:34
</code>
Here's my code - test.rb
<code>
amount = 60
@threads = []
1.upto(amount) { |i|
@threads << Thread.new do
puts "New Thread Created #{i}"
# This thread makes 10 post requests
1.upto(10) { |j|
puts "Thread #{i} Try #{j}"
# => DO post request using Net:HTTP
Net::HTTP.start("localhost", "80") do |http|
response = http.request_post("/test/mypost.php?get=value",
"a=b,c=d")
end
}
end
}
# Join all the threads we have created
@threads.each{ |thr|
thr.join # Timeout:ERror thrown here after approx 1.5 mins
}
</code>
Wrapping my thread.join call around Timeout::timeout (http://www.ruby-
doc.org/stdlib/libdoc/timeout/rdoc/classes/Timeout.html) didn't help
either.
Any suggestions how to make it *not* timeout so that I can finish
making all the API calls? I've tried hard but haven't been able to
find a solution