Skip to content

Commit

Permalink
general exception handling added
Browse files Browse the repository at this point in the history
  • Loading branch information
lchi committed Apr 17, 2012
1 parent 62cce7f commit 13df8c3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
11 changes: 11 additions & 0 deletions examples/threadpool_exception.rb
@@ -0,0 +1,11 @@
#!/usr/bin/env ruby

require 'bundler/setup'

require 'eventless'

Eventless.threadpool.schedule do
raise Exception, "Exception in the threadpool"
end

sleep 2
10 changes: 8 additions & 2 deletions lib/eventless/threadpool.rb
Expand Up @@ -22,8 +22,14 @@ def initialize(threadpool_size=10)
threadpool_size.times do threadpool_size.times do
@workers << Thread.new do @workers << Thread.new do
loop do loop do
task = queue.pop begin
task.call task = queue.pop
task.call
# TODO: Should indicate which fiber raised this exception
rescue StandardError, Exception => e
p e.message
puts e.backtrace
end
end end
end end
end end
Expand Down

0 comments on commit 13df8c3

Please sign in to comment.