-
-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Description
First I thought it was celluloid-io sockets, but then I realized that in Jruby, timeouts will not always be triggered. Here is a simple script:
require 'time'
require 'celluloid/io'
class Tester
include Celluloid::IO
def initialize
@sock = TCPSocket.new("localhost", 80)
end
def test_timeout
begin
timeout(2) do
# option 1
# @sock.wait_readable
# option 2
# sleep 3
# option 3
loop do
sleep 1
end
end
rescue Celluloid::Task::TimeoutError
puts "successfull timeout fetch: #{Time.now}"
retry
ensure
puts "#{$!.class} #{$!.message}" if $!
end
end
end
puts "starting the actor..."
t = Tester.new
t.async(:test_timeout)
sleep
# Option 1
# Both MRI 2.1 and jruby 9.0.5.0
....
successfull timeout fetch: 2016-01-27 18:50:47 +0100
successfull timeout fetch: 2016-01-27 18:50:49 +0100
successfull timeout fetch: 2016-01-27 18:50:51 +0100
successfull timeout fetch: 2016-01-27 18:50:53 +0100
successfull timeout fetch: 2016-01-27 18:50:55 +0100
successfull timeout fetch: 2016-01-27 18:50:57 +0100
successfull timeout fetch: 2016-01-27 18:50:59 +0100
successfull timeout fetch: 2016-01-27 18:51:01 +0100
(hangs at some point...)
# Option 2
# MRI 2.1 and JRUBY-9.0.5.0
starting the actor...
successfull timeout fetch: 2016-01-27 18:49:12 +0100
W, [2016-01-27T18:49:15.799990 #328595] WARN -- : Attempted to resume a dead task: type=:call, meta={:dangerous_suspend=>false, :method_name=>:test_timeout}, status=:deadOption 3 works in MRI (apparently), but also hangs at some point.
This can seriously hinder celluloid/celluloid-io#170.
Metadata
Metadata
Assignees
Labels
No labels