Monday, 15 August 2011

Use ruby parallel gem and pass variables to main -



Use ruby parallel gem and pass variables to main -

i trying speed parallel gem. works have problem. want nil overwrite test. or array out have output.but result nil. how can create happen ? have advise folks.

require 'parallel' genes=[[1,nil],[2,nil],[3,nil],[4,nil],[5,nil],[6,nil],[7,nil],[8,nil]] out =[] parallel.each(genes, in_threds: 4) |g| g[1] = "test" out << g end p genes p out

--result--- [[1, nil], [2, nil], [3, nil], [4, nil], [5, nil], [6, nil], [7, nil], [8, nil]] []

i noticed have typo in "in_threads" portion of parallel command. 1 time tried in_threads instead of in_threds, got output believe expecting.

output expecting: [[1, "test"], [3, "test"], [2, "test"], [4, "test"], [5, "test"], [6, "test"], [8, "test"], [7, "test"]]

ruby parallel-processing gem

No comments:

Post a Comment