4

Is there a module for Ruby that makes it easy to share objects between multiple processes? I'm looking for something similar to Python's multiprocessing, which supports process-safe queues and pipes that can be shared between processes.

3 Answers 3

3

I think you can do a lot of what you want using the facilities of Ruby IO; you're sharing between processes, not threads, correct?

If that's the case, IO.pipe will do what you need. Ruby doesn't have any built-in way of handling cross-process queues (to my knowledge), but you can also use FIFOs (if you're on Unix).

If you want something more fine-grained, and with good threading support, I'm fairly certain that you can piggyback on java.util.concurrent if you use JRuby. MRI has pretty lousy threading/concurrency support, so if that's what your aiming for, JRuby is probably a better place to go.

Sign up to request clarification or add additional context in comments.

1 Comment

I've used it in both perl and ruby. It's freaking awesome.
2

I've run into this library but I haven't tried it yet.

Parallel::ForkManager — A simple parallel processing fork manager.

http://parallelforkmgr.rubyforge.org/

Comments

1

Combining DRb, which provides simple inter-process communication, with Queue or SizedQueue, which are both threadsafe queues, should give you what you need.

You may also want to check out beanstalkd which is also hosted on github

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.