From: Eric Wong Date: 2013-11-24T04:42:12+00:00 Subject: [ruby-core:58547] Re: [ruby-trunk - Feature #9145][Feedback] Queue#pop(true) return nil if empty instead of raising ThreadError "Glass_saga (Masaki Matsushita)" wrote: > I think we can't change default behavior of Queue#pop(true) because some code expects ThreadError to be raised. > However, it may be possible to introduce new keyword argument like following: > > q = Queue.new > while next_item = q.pop(true, exception: false) # it doesn't raise ThreadError and returns nil. > # do something > end +1 to that. All non-blocking methods (I/O or not) should support exception: false to avoid (expensive/noisy-on-$DEBUG=$true) exceptions.