Robert Klemme
5/15/2006 7:09:00 AM
uncutstone wrote:
> This is discussion about "A tricky problem about Process.wait and popen
> " . I post it here because I cannot post it in that thread. Maybe it
> is full. I don't know.
Um... Since this is a usenet newsgroup I don't think it can ever be
"full". I'm not sure what problems you are experiencing. Maybe they
are related to the fact that you're posting from China.
> Robert Klemme write:
>
>> Then place a loop into the thread block.
>> No, you probably did not understand my code fully: it waits for all
>> *threads* to terminate! The script creates PARALLEL (i.e. 10) threads
>> and each of them forks a ruby process and terminates once the child
>> process has terminated. So you got 10 processes executing in parallel
>> and the script waits for all to terminate.
>
> Yes , it works and I fully understood your code. :-)
Ok, fine.
>> I don't think you need DRb for this. It seems the number of child
>> processes is an input parameter. You just need to add that to my
>> script. Then decrement a counter thread safe and have each thread start
>> a new process as long as you are not done. It's an easy change to the
>> script I provided earlier.
>
> IMHO, I think DRb has some advantage when there is lots of info to
> transfer between processes that's just what I want. The code I listed
> earlier was simplified so you cannot see that. By using DRb, the code
> is more concise, simpler and easier to understand.
Ah, I see. Yes in that case the DRb approach is probably better. In
that case I'd still use fork with a block to spawn child processes - the
big advantage is that you do not have to fiddle with path information
(e.g. if "ruby" is not on your path) and you do not have to transfer
information (i.e. DRb port number) via command line arguments. It may
or may not be a disadvantage to have all the code in one script - that
depends; OTOH if it's larger then it's probably reasonable to place
classes in separate files anyway.
> Thanks, it is my pleasure to discuss with you .
Ditto.
Kind regards
robert