-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Process.on_terminate proc cannot be executed? #14836
Comments
With just the above code, the program will always exit with no output because there is no interrupt/terminate signal sent to the program, it terminates itself. The |
why CTRL+C not sent interrupt/terminate signal sent to the program? and same issue when |
the mainly code is spawnning 16 fibers to consume downloading task from task queue and download something from remote server |
In that case it's possible there is some fiber in a tight loop that is not blocking/yielding which is not allowing the main fiber to run/execute the |
Process.on_terminate do |reason|
case reason
when .interrupted?
puts "Signal : interrupted"
when .terminal_disconnected?
puts "Signal : terminal disconnected"
when .session_ended?
puts "Signal : session ended"
end
puts "Hook exit"
Process.exit
end
chan = Channel(Nil).new(16)
(1..16).each do
spawn do
begin
loop { }
ensure
chan.send nil
puts "Fiber exit"
end
end
end
(1..16).each do
chan.receive
end
puts "Main exit"
Maybe running the signal listener on a separate thread (not sharing with worker fibers) can avoid this problem My real program fibers is waiting network io, it should be yield automically, but same problem was occurred |
|
Going to close this as a duplicate of #1454. Until that is resolved you'll need to ensure none of your fibers in user code will block forever/starve the main fiber. |
Duplicate of #1454 |
Skill issue Solution: I should use Go lang ;-) |
When I press CTRL+C, the program will be blocked all the time, and the on_termiante proc will not be executed to print and exit the program.
I want to know under what circumstances will it be blocked?
Or how can I debug the program to find out what is causing it to get blocked?
The text was updated successfully, but these errors were encountered: