Permalink
Browse files

general exception handling added

  • Loading branch information...
lchi committed Apr 17, 2012
1 parent 62cce7f commit 13df8c3b6d182dfb19333bee25b3b6de79f81c6e
Showing with 19 additions and 2 deletions.
  1. +11 −0 examples/threadpool_exception.rb
  2. +8 −2 lib/eventless/threadpool.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
@@ -22,8 +22,14 @@ def initialize(threadpool_size=10)
threadpool_size.times do
@workers << Thread.new do
loop do
- task = queue.pop
- task.call
+ begin
+ 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

0 comments on commit 13df8c3

Please sign in to comment.