Created
June 15, 2013 14:15
-
-
Save felixyz/5788285 to your computer and use it in GitHub Desktop.
Creating and running >120 Celluloid::IO actors raises an error on MRI, even when doing NO I/O
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Running on OS X | |
# JRuby + Celluloid = OK | |
# MRI + Celluloid = OK | |
# JRuby + Celluloid::IO = OK | |
# MRI + Celluloid::IO = Too many open files - pipe (Errno::EMFILE) | |
require 'celluloid/io' | |
class SimpleActor | |
# include Celluloid # Creating regular Celluloid actors works on MRI | |
include Celluloid::IO # Creating >120 (approx.) Celluloid::IO actors on MRI rasies Too many open files - pipe (Errno::EMFILE) | |
def do_work(id) | |
puts "[#{id}] Starting..." | |
result = 0 | |
10_000.times do | |
result += rand 1..8 | |
end | |
result | |
end | |
end | |
results = 1_000.times.map { |n| | |
SimpleActor.new.future :do_work, n | |
}.each{|future| puts future.value } |
The actual problem is not with MRI but with a low default limit number of allowed file descriptors on OSX (10.8.2)
@felixyz, i just came across this (obscure) error. have you found any other solutions? i'm looking for a way to terminate existing Celluloid actors without having to raise the open files limit on the system.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The actual problem is with MRI, not Celluloid::IO: https://gist.github.com/Felixyz/5788375