Skip to content

Commit

Permalink
Use Fiber#alive? to detect it is finished or not
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 14, 2015
1 parent d8c701b commit e2f4ea8
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/droonga/plugin/async_command.rb
Expand Up @@ -13,6 +13,7 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

require "fiber"
require "coolio"

require "droonga/loggable"
Expand Down Expand Up @@ -102,18 +103,18 @@ def start

timer = Coolio::TimerWatcher.new(0.1, true)
timer.on_timer do
begin
runner.resume
rescue FiberError
if runner.alive?
begin
runner.resume
rescue
timer.detach
logger.trace("start: watcher detached on unexpected exception",
:watcher => timer)
logger.exception(error_message, $!)
error(error_name, error_message)
end
else
timer.detach
logger.trace("start: watcher detached on FiberError",
:watcher => timer)
rescue
timer.detach
logger.trace("start: watcher detached on unexpected exception",
:watcher => timer)
logger.exception(error_message, $!)
error(error_name, error_message)
end
end

Expand Down

0 comments on commit e2f4ea8

Please sign in to comment.