New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
External Shutdown Does Not Complete #150
Conversation
This will be because the
|
OK, after running this on a more recent version of Celluloid with insane debugging, I found that when you call This causes major problems because the actor thread is unable to continue to operate. One solution to this is to use the |
And another problem is you call run and terminate both by sync call. this mean |
seems no good way to sync terminate |
@jjyr it is possible, the current implementation of the actor stops handling messages when |
@halorgium yes, i'm wrong, when terminate timer will never be fired |
@jjyr I am not sure I understand what you mean. require 'celluloid'
class LOL
include Celluloid
def run
loop { puts "run loop"; sleep 0.1 }
end
end
l = LOL.new
l.after(1) { l.terminate }
l.async.run
puts "..."
sleep The timer does fire, but then the Here is the backtrace of the actor thread.
The actor has 2 tasks running at this stage.
|
@halorgium Yes, you're right. def join
@mutex.synchronize do
if @thread == Thread.current
raise 'deadlock'
elsif @thread
@join.wait(@mutex)
end
end
self
end can fix it, but i not really known why the old version crashed and never return |
#terminate provides synchronous behavior #terminate! provides asynchronous behavior Does #terminate! suit your needs? On Sun, Apr 14, 2013 at 1:55 AM, Tim Carey-Smith
Tony Arcieri |
@tarcieri are we able to solve the underlying issue here? |
@halorgium if I understand correctly, the issue is with self-referential joins? If so, Celluloid should probably raise in that case rather than deadlocking. |
Do you mean the Actor thread is joined to itself? I had thought that ruby did not allow such a behaviour! |
There is not. The Ruby behavior is:
I am not sure how @jjyr is affecting a self-referential join (or if that is really what's happening here), but it should definitely raise some kind of exception if it happens. |
External Shutdown Does Not Complete
The strange is the actor thread should be blocked forever(because self-join), but it crashed in @gf3 's code |
@jjyr there was several changes to Celluloid which modified the behaviour. |
When terminating actors externally, they seem to "stop what they're doing" but they don't return, which can prevent further code from running.
Note: This is on JRuby
1.7.2
and Celluloid0.12.4
.The following example kills the loop as expected, but it never returns:
Whereas calling
#terminate
internally functions as expected: