Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Ruby's equivalent to Python's multiprocessing module?

To get real concurrency in Ruby or Python, I need to create new processes. Python makes this pretty straightforward using the multiprocessing module, which abstracts away all the fork / wait goodness and lets me concentrate on my code. Does Ruby have something similar? Right now I am calling Process.fork and Process.wait to get my concurrency, and I want a cleaner solution.

like image 936
Vlad the Impala Avatar asked Aug 31 '11 23:08

Vlad the Impala


1 Answers

I have used https://github.com/grosser/parallel, and like it a lot. It will #map or #each across all the cores in your system by default. Under the hood it's a wrapper around Process.fork, which sounds like what you're asking for.

like image 105
Ben Nagy Avatar answered Nov 14 '22 23:11

Ben Nagy