multithreading - Ruby process forking / threading - child process lifetime -


i main function basic loop inside it. want fire off child process every iteration of loop (that goes off doing http request, more on later).

if using processes, problem looks each child process continues execution of main thread, whereas want main process go on after loop, , children die after http req finished. main process not interested in each child finish before continuing.

looks now:

data.each |k, v|   (pid = fork) ? process.detach(pid) : dohttpquery(v + ":" + "k") end # code after comment should executed once 

also, when processes finish, this

thread.rb:189:in `sleep': deadlock detected (fatal) 

if use threads this

threads << thread.new { dohttpquery(v + ":" + "k")} 

and then

threads.each { |thr| thr.join } 

the threads fired, reason not doing http request, , whole process comes halt.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -