Skip to content

fix: race condition with interruptibles #566

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/solid_queue/processes/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ module SolidQueue
module Processes
class Base
include Callbacks # Defines callbacks needed by other concerns
include AppExecutor, Registrable, Interruptible, Procline
include AppExecutor, Registrable, Procline
prepend Interruptible

attr_reader :name

Expand Down
11 changes: 7 additions & 4 deletions lib/solid_queue/processes/interruptible.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

module SolidQueue::Processes
module Interruptible
attr_reader :self_pipe

def initialize(...)
super
@self_pipe = create_self_pipe
end

def wake_up
interrupt
end
Expand All @@ -25,10 +32,6 @@ def interruptible_sleep(time)
end

# Self-pipe for signal-handling (http://cr.yp.to/docs/selfpipe.html)
def self_pipe
@self_pipe ||= create_self_pipe
end

def create_self_pipe
reader, writer = IO.pipe
{ reader: reader, writer: writer }
Expand Down
Loading