File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
lib/concurrent-ruby/concurrent/executor Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 33require 'concurrent/collection/non_concurrent_priority_queue'
44require 'concurrent/executor/executor_service'
55require 'concurrent/executor/single_thread_executor'
6-
6+ require 'concurrent/errors'
77require 'concurrent/options'
88
99module Concurrent
@@ -162,7 +162,11 @@ def process_tasks
162162 # queue now must have the same pop time, or a closer one, as
163163 # when we peeked).
164164 task = synchronize { @queue . pop }
165- task . executor . post { task . process_task }
165+ begin
166+ task . executor . post { task . process_task }
167+ rescue RejectedExecutionError
168+ # ignore and continue
169+ end
166170 else
167171 @condition . wait ( [ diff , 60 ] . min )
168172 end
Original file line number Diff line number Diff line change @@ -122,6 +122,20 @@ module Concurrent
122122 expect ( task . value ) . to eq i
123123 end
124124 end
125+
126+ it 'safely handles an executor raising RejectedExecutionError' do
127+ # force a task's executor to raise RejectedExecutionError within the TimerSet
128+ abort_executor = ImmediateExecutor . new
129+ allow ( abort_executor ) . to receive ( :post ) . and_raise ( Concurrent ::RejectedExecutionError )
130+ ScheduledTask . execute ( 0.2 , executor : abort_executor , timer_set : subject ) { nil }
131+ abort_executor . shutdown
132+
133+ latch = CountDownLatch . new ( 1 )
134+ ScheduledTask . execute ( 0.3 , timer_set : subject ) do
135+ latch . count_down
136+ end
137+ expect ( latch . wait ( 1 ) ) . to be_truthy
138+ end
125139 end
126140
127141 context 'resolution' do
You can’t perform that action at this time.
0 commit comments