Skip to content

Instantly share code, notes, and snippets.

@riverock
Last active December 29, 2015 01:09
Show Gist options
  • Save riverock/7590975 to your computer and use it in GitHub Desktop.
Save riverock/7590975 to your computer and use it in GitHub Desktop.
Sample script demonstrating a warning that listen 2.3.0 displays when stopping a second Listen instance
# Using Ruby 2.0.0p195 and listen 2.3.0
require 'listen'
listener1 = Listen.to('dir1')
listener2 = Listen.to('dir2')
listener1.start
listener2.start
begin
listener1.stop
rescue SystemExit
puts "listener1: Eat #{$!.class} exception"
end
begin
listener2.stop
rescue SystemExit
puts "listener2: Eat #{$!.class} exception"
end
puts "Done!"
# The following appears in the console. Warning is triggered by stopping the second listner (line 17).
#
# listener1: Eat SystemExit exception
# [Listen warning]: Change block raised an exception: actor already terminated
# Backtrace:
# /Users/blue39/.rvm/gems/ruby-2.0.0-p195@listen_test/gems/celluloid-0.15.2/lib/celluloid/proxies/actor_proxy.rb:66:in `terminate!'
# /Users/blue39/.rvm/gems/ruby-2.0.0-p195@listen_test/gems/celluloid-0.15.2/lib/celluloid/proxies/actor_proxy.rb:59:in `terminate'
# /Users/blue39/.rvm/gems/ruby-2.0.0-p195@listen_test/gems/listen-2.2.0/lib/listen/listener.rb:158:in `_terminate_actors'
# /Users/blue39/.rvm/gems/ruby-2.0.0-p195@listen_test/gems/listen-2.2.0/lib/listen/listener.rb:141:in `_wait_for_changes'
# /Users/blue39/.rvm/gems/ruby-2.0.0-p195@listen_test/gems/listen-2.2.0/lib/listen/listener.rb:40:in `block in start'
# Done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment