-
-
Save ccoenen/7d39c37d72d4c2a5df1d to your computer and use it in GitHub Desktop.
Celluloid on Windows with ThreadError: Deadlock exception
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: | |
:: here's what i'm seeing in my terminal | |
:: | |
:: Related bug: https://github.com/celluloid/celluloid-io/issues/74 | |
bundle exec ruby .\echo.rb -p 3773 -l localhost | |
DL is deprecated, please use Fiddle | |
I, [2014-11-05T23:36:03.683417 #12888] INFO -- : ** Starting echo server on localhost:3773 | |
I, [2014-11-05T23:36:03.699043 #12888] INFO -- : ** Enter connection loop | |
D, [2014-11-05T23:36:03.699043 #12888] DEBUG -- : test1 | |
E, [2014-11-05T23:36:09.894995 #12888] ERROR -- : Actor crashed! | |
ThreadError: deadlock; recursive locking | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/gems/nio4r-1.0.1/lib/nio/selector.rb:40:in `synchronize' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/gems/nio4r-1.0.1/lib/nio/selector.rb:40:in `deregister' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/gems/nio4r-1.0.1/lib/nio/monitor.rb:40:in `close' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-io-1b79f698c850/lib/celluloid/io/reactor.rb:51:in `block in run_once' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/gems/nio4r-1.0.1/lib/nio/selector.rb:94:in `block (2 levels) in select' | |
C:/Tools/Ruby213/lib/ruby/2.1.0/set.rb:263:in `each_key' | |
C:/Tools/Ruby213/lib/ruby/2.1.0/set.rb:263:in `each' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/gems/nio4r-1.0.1/lib/nio/selector.rb:93:in `block in select' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/gems/nio4r-1.0.1/lib/nio/selector.rb:54:in `synchronize' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/gems/nio4r-1.0.1/lib/nio/selector.rb:54:in `select' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-io-1b79f698c850/lib/celluloid/io/reactor.rb:49:in `run_once' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/evented_mailbox.rb:48:in `check' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/actor.rb:153:in `block in run' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/gems/timers-4.0.1/lib/timers/group.rb:52:in `wait' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/actor.rb:150:in `run' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/actor.rb:130:in `block in start' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/thread_handle.rb:13:in `block in initialize' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/actor_system.rb:32:in `block in get_thread' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/internal_pool.rb:129:in `call' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/internal_pool.rb:129:in `block in create' | |
I, [2014-11-05T23:36:10.035615 #12888] INFO -- : ** closing server | |
D, [2014-11-05T23:36:10.035615 #12888] DEBUG -- : Terminating task: type=:call, meta={:method_name=>:run}, status=:iowait | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/tasks/task_thread.rb:32:in `pop' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/tasks/task_thread.rb:32:in `signal' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/tasks.rb:85:in `suspend' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/tasks.rb:24:in `suspend' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-io-1b79f698c850/lib/celluloid/io/reactor.rb:44:in `wait' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-io-1b79f698c850/lib/celluloid/io/reactor.rb:21:in `wait_readable' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-io-1b79f698c850/lib/celluloid/io.rb:53:in `wait_readable' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-io-1b79f698c850/lib/celluloid/io/tcp_server.rb:19:in `accept' | |
C:/Users/....../tcp_bridge.rb:35:in `block in run' | |
C:/Users/....../tcp_bridge.rb:33:in `loop' | |
C:/Users/....../tcp_bridge.rb:33:in `run' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/calls.rb:26:in `public_send' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/calls.rb:26:in `dispatch' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/calls.rb:122:in `dispatch' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/cell.rb:60:in `block in invoke' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/cell.rb:71:in `block in task' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/actor.rb:357:in `block in task' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/tasks.rb:57:in `block in initialize' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/tasks/task_thread.rb:21:in `block in create' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/thread_handle.rb:13:in `block in initialize' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/actor_system.rb:32:in `block in get_thread' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/internal_pool.rb:129:in `call' | |
C:/Tools/Ruby213/lib/ruby/gems/2.1.0/bundler/gems/celluloid-a6584e787926/lib/celluloid/internal_pool.rb:129:in `block in create' | |
I, [2014-11-05T23:36:10.035615 #12888] INFO -- : ** Starting echo server on localhost:3773 | |
I, [2014-11-05T23:36:10.235180 #12888] INFO -- : ** Enter connection loop | |
D, [2014-11-05T23:36:10.235180 #12888] DEBUG -- : test1 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'bundler/setup' | |
require 'optparse' | |
require 'celluloid' | |
Celluloid.task_class = Celluloid::TaskThread | |
require_relative 'tcp_bridge' | |
options = TCPBridge::DEFAULT_OPTIONS.clone | |
OptionParser.new do |opts| | |
opts.on('-p N', '--port', "specify port to listen. Defaults to #{TCPBridge::DEFAULT_OPTIONS[:port]}") do |n| | |
options[:port] = n | |
end | |
opts.on('-l IP', '--listen_ip', "specify ip to listen on. Defaults to #{TCPBridge::DEFAULT_OPTIONS[:listen_ip]}") do |ip| | |
options[:listen_ip] = ip | |
end | |
end.parse! | |
supervisor = TCPBridge.supervise(options) | |
trap("INT") { | |
Celluloid.logger.info "** Interrupt Received, Terminating" | |
Thread.new { supervisor.terminate if supervisor.alive? }.join | |
exit | |
} | |
sleep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'celluloid', :git => 'https://github.com/celluloid/celluloid.git' | |
gem 'celluloid-io', :git => 'https://github.com/celluloid/celluloid-io.git' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'celluloid/io' | |
require 'celluloid/autostart' | |
class TCPBridge | |
include Celluloid::IO | |
include Celluloid::Logger | |
finalizer :finalize | |
DEFAULT_OPTIONS = { | |
listen_ip: '0.0.0.0', | |
port: 3772 | |
} | |
def initialize(passed_options = {}) | |
opts = DEFAULT_OPTIONS.merge(passed_options) | |
info "** Starting echo server on #{opts[:listen_ip]}:#{opts[:port]}" | |
server = TCPServer.new(opts[:listen_ip], opts[:port]) | |
@server = Celluloid::IO::TCPServer.from_ruby_server(server) | |
async.run | |
end | |
def finalize | |
info "** closing server" | |
@server.close unless @server.closed? | |
end | |
def run | |
info "** Enter connection loop" | |
loop { | |
debug "test1" | |
async.handle @server.accept | |
debug "never got here" | |
} | |
end | |
def handle connection | |
connection << "hi" | |
connection.close | |
rescue EOFError | |
connection.close unless connection.closed? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment