ruby-concurrency / ruby-concurrency/concurrent-ruby
ThreadPoolExecutor#kill: documentation and implementation are out of sync
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 5.8k
- Forks
- 420
- Avg merge
- 20h 45m
- Merged PRs (30d)
- 4
Description
* Operating system: mac
* Ruby implementation: Ruby
* `concurrent-ruby` version: 1.3.4
* `concurrent-ruby-ext` installed: no
* `concurrent-ruby-edge` used: no
The docs for ThreadPoolExecutor#kill suggest that inflight tasks will run to completion.
#kill
Begin an immediate shutdown. In-progress tasks will be allowed to complete but enqueued tasks will be dismissed and no new tasks will be accepted. Has no additional effect if the thread pool is not running.
This (maybe too) simple test suggests the Executor will kill its internal threads and not allow them to finish.
e = Concurrent::ThreadPoolExecutor.new
f = Concurrent::Promises.future_on(e) { sleep 10; puts "I'm alive!" }
sleep 11
I'm alive!
f = Concurrent::Promises.future_on(e) { sleep 10; puts "I'm alive!" }
e.kill
e.shutdown? => true
# future f never completes
The code for #kill in ruby_executor_service.rb:
def kill
synchronize do
break if shutdown?
stop_event.set
ns_kill_execution
stopped_event.set
end
true
end
ns_kill_execution:
def ns_kill_execution
# TODO log out unprocessed tasks in queue
# TODO try to shutdown first?
@pool.each(&:kill)
@pool.clear
@ready.clear
end
and @pool.each(&:kill) concludes with:
def kill
@thread.kill
end
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Compare the ThreadPoolExecutor#kill documentation with the kill and ns_kill_execution methods in ruby_executor_service.rb, including the worker kill behavior shown in the issue. Determine the intended handling of in-progress and queued tasks, then update the implementation or documentation so they agree and verify the observed future behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100