You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.
As a disclaimer, I've never worked with celluloid/celluloid-io before today but I can't find any mention of sleep being considered unsafe inside of an actor. Everything was going well with my experiments until I started encountering strange deadlocks. I managed to reduced the problem down to this minimal test case which seems to show some sort of odd interaction between sleep/timers running in the same method as a redis method invocation, but only if the redis method is called before the sleep.
#!/usr/bin/env ruby
require 'celluloid/io'
require 'celluloid/redis'
require 'redis/connection/celluloid'
class RedisTest
include Celluloid::IO
def initialize
@redis = ::Redis.new
end
def lookup_redis
puts "redis lookup"
@redis.lindex 'fooq', 0
puts "redis returned\n\n"
end
def yawn
puts "going to sleep"
sleep 1
puts "wokeup\n\n"
end
def yawn_and_lookup_redis
puts "going to sleep"
sleep 1
puts "wokeup"
puts "redis lookup"
record = @redis.lindex 'fooq', 0
puts "redis returned\n\n"
end
def lookup_redis_and_yawn
puts "redis lookup"
record = @redis.lindex 'fooq', 0
puts "redis returned"
puts "going to sleep"
sleep 1
puts "wokeup\n\n"
end
end
rt = RedisTest.new
rt.lookup_redis
rt.yawn
rt.yawn_and_lookup_redis
rt.lookup_redis_and_yawn
The output I get is:
redis lookup
redis returned
going to sleep
wokeup
going to sleep
wokeup
redis lookup
redis returned
redis lookup
redis returned
going to sleep
<hangs>
If I comment out the line require 'redis/connection/celluloid', so that redis uses it's default connection driver, the script exits normally with the expected output.
The text was updated successfully, but these errors were encountered:
As a disclaimer, I've never worked with celluloid/celluloid-io before today but I can't find any mention of sleep being considered unsafe inside of an actor. Everything was going well with my experiments until I started encountering strange deadlocks. I managed to reduced the problem down to this minimal test case which seems to show some sort of odd interaction between sleep/timers running in the same method as a redis method invocation, but only if the redis method is called before the sleep.
The output I get is:
If I comment out the line
require 'redis/connection/celluloid'
, so that redis uses it's default connection driver, the script exits normally with the expected output.The text was updated successfully, but these errors were encountered: