-
-
Notifications
You must be signed in to change notification settings - Fork 108
Reimplement ThreadingFuture[T] to use condition variable instead of queue
#233
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
Reimplement ThreadingFuture[T] to use condition variable instead of queue
#233
Conversation
|
I'm on vacation. Will have a look at this as soon as I'm back. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #233 +/- ##
==========================================
- Coverage 93.63% 93.45% -0.19%
==========================================
Files 14 14
Lines 550 565 +15
Branches 46 49 +3
==========================================
+ Hits 515 528 +13
- Misses 31 32 +1
- Partials 4 5 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No worries have a great rest of your vacation! |
ThreadingFuture[T] to use condition variable instead of queue
2873d71 to
0c0a841
Compare
|
I've looked through your fix, and I think it looks like a good improvement. And all the tests pass without modification 😌 I've added five small refactoring commits that I think improves it even further. The first four I think are non-controversial, but I'd like to hear your thoughts about the last one (0c0a841). |
|
@jodal Thanks yes I agree with the first four. The fifth one the only thing is that I wanted to avoid the On the topic of the |
Condition.notify_all() is a no-op if there are no waiters.
It uses an underlying RLock by default, so this is functionally equivalent.
0c0a841 to
2fa83a8
Compare
|
I did the stupid thing of removing Python 3.9 support and upgrading the syntax to 3.10 with this PR open, so I had the pleasure of rebasing this PR now 😅 I think that it is the right choice to hold the lock while running
I agree it could be a good thing to enforce that only calling one of the setters is allowed. I'll see about doing that in a follow-up PR. |
This should now be fixed in #239. |
This should now be fixed in #240. |
Re implement to use
threading.Conditioninstead ofqueue.Queueto eliminate the race conditions. Also protects the base classFuture[T]state (i.e_get_hookand_get_hook_result) with the lock (if any) passed to it from a derived class. Right now the only derived class isThreadingFuture[T]which passes anRLocktoFuture[T].Fixes #232