Hi Everyone,
Process::Group
is a class for coordinating and managing multiple
processes which execute concurrently in fibers.
In some of my testing scripts, multiple processes need to run. In the
past,
I’ve just done this sequentially. However, I’ve been modernising some
scripts and I’ve bundled up the code into this gem.
Previously:
Process.spawn(“some-task”)
process_and_email_results
Process.spawn(“some-other-task --foobar”)
process_and_email_results
Now I can run like this:
group = Process::Group.new
Fiber.new do
group.spawn(“some-task”)
process_and_email_results
end.resume
Fiber.new do
group.spawn(“some-other-task --foobar”)
process_and_email_results
end.resume
group.wait
Process::Group allows you to run the two tasks concurrently and in these
cases it was an easy option to modernise existing scripts. You can call
spawn multiple times in a fiber and it will work as expected. You can
also
kill the entire group of processes if you wish.
Examples, documentation and code:
Kind regards,
Samuel