Skip to content
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

Make AbstractWorkerPool methods thread-safe and more consistent #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JamesWrigley
Copy link
Collaborator

Previously they did not handle dead workers in the same way. In particular take! would remove dead workers but none of the other methods did, leading to cases where isready might return true but take! would still block.

Now they should all be consistent with each other; except for wait which will block if the pool is empty, unlike take! which will throw an exception. This seems like a reasonable tradeoff to minimize breakage while still ensuring that 'take!() will block if wait() blocks' holds.

In theory one could put the dead worker checks in other methods like length and put!, but the checks would still need to be in take!/isready etc so it seems simpler to just acknowledge the lack of thread-safety in these methods upfront.

Fixes JuliaLang/Distributed.jl#87. If this is merged I'll backport it to Distributed.

Previously they did not handle dead workers in the same way. In particular
`take!` would remove dead workers but none of the other methods did, leading to
cases where `isready` might return true but `take!` would still block.

Now they should all be consistent with each other; except for `wait` which will
block if the pool is empty, unlike `take!` which will throw an exception. This
seems like a reasonable tradeoff to minimize breakage while still ensuring that
'take!() will block if wait() blocks' holds.

In theory one could put the dead worker checks in other methods like `length`
and `put!`, but the checks would still need to be in `take!`/`isready` etc so it
seems simpler to just acknowledge the lack of thread-safety in these methods
upfront.
@JamesWrigley JamesWrigley requested a review from jpsamaroo January 8, 2025 18:57
@JamesWrigley JamesWrigley self-assigned this Jan 8, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jan 8, 2025

Codecov Report

Attention: Patch coverage is 90.62500% with 3 lines in your changes missing coverage. Please review.

Project coverage is 88.27%. Comparing base (0cca4d3) to head (390047b).

Files with missing lines Patch % Lines
src/workerpool.jl 90.62% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #21      +/-   ##
==========================================
+ Coverage   88.24%   88.27%   +0.02%     
==========================================
  Files          11       11              
  Lines        2068     2090      +22     
==========================================
+ Hits         1825     1845      +20     
- Misses        243      245       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

isready(::AbstractWorkerPool) is inconsistent with whether take! will block
2 participants