Skip to content

Commit

Permalink
Support waking up blocking pop in Puma::QueueClose
Browse files Browse the repository at this point in the history
Ruby 2.2 support for drain_on_shutdown test.
  • Loading branch information
wjordan committed Apr 18, 2021
1 parent 98d325f commit 98df869
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/puma/queue_close.rb
Expand Up @@ -5,22 +5,22 @@ module Puma
# Add a simple implementation for earlier Ruby versions.
#
module QueueClose
def initialize
@closed = false
super
end
def close
num_waiting.times {push nil}
@closed = true
end
def closed?
@closed
@closed ||= false
end
def push(object)
@closed ||= false
raise ClosedQueueError if @closed
raise ClosedQueueError if closed?
super
end
alias << push
def pop(non_block=false)
return nil if !non_block && closed? && empty?
super
end
end
::Queue.prepend QueueClose
end

0 comments on commit 98df869

Please sign in to comment.