Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

general exception handling added

  • Loading branch information...
commit 13df8c3b6d182dfb19333bee25b3b6de79f81c6e 1 parent 62cce7f
@lchi lchi authored
Showing with 19 additions and 2 deletions.
  1. +11 −0 examples/threadpool_exception.rb
  2. +8 −2 lib/eventless/threadpool.rb
View
11 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
View
10 lib/eventless/threadpool.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.