Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spawning within threads throws exception #2

Closed
wr0ngway opened this issue May 22, 2009 · 2 comments
Closed

Spawning within threads throws exception #2

wr0ngway opened this issue May 22, 2009 · 2 comments

Comments

@wr0ngway
Copy link

Using fork method for spawn. I have a daemon which spawns jobs on request, but I wanted to limit concurrency, so created 3 worker threads to do the spawning within. I then ran into this race condition, and extracted the failure into the simplified code below. Any ideas? I was unable to figure out what is going wrong. Its probably something weird in my environment as I can't duplicate it in a fresh rails app

foo.rb:
class SpawnInit
include Spawn
def initialize
sid = spawn do
puts "Spawn initialized"
end
wait([sid])
end
end

threads = []
threads << Thread.new { SpawnInit.new }
threads << Thread.new { SpawnInit.new }
threads.each {|t| t.join}

within RAILS_ROOT

./script/runner foo.rb

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:285:in stop': stopping only thread (ThreadError) note: use sleep to stop forever from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:285:inmon_acquire'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:214:in mon_enter' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:240:insynchronize'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/logger.rb:496:in write' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/logger.rb:326:inadd'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/logger.rb:374:in info' from /Users/mconway/Documents/eclipse/workspace/sml/vendor/plugins/spawn/lib/spawn.rb:118:infork_it'
from /Users/mconway/Documents/eclipse/workspace/sml/vendor/plugins/spawn/lib/spawn.rb:90:in fork' ... 9 levels... from /Users/mconway/Documents/eclipse/workspace/sml/vendor/rails/railties/lib/commands/runner.rb:45 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:ingem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from ./script/runner:3
Spawn initialized

@wr0ngway
Copy link
Author

Some more info, this does happen with a fresh rails app once you replace the logger in environment.rb:
config.logger = Logger.new(config.log_path)

@mnoack
Copy link
Collaborator

mnoack commented Jul 6, 2014

Closing to clean up as this in an old issue, if this is still valid on the latest version of spawnling then please re-open the issue and I will address it.

@mnoack mnoack closed this as completed Jul 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants