-
-
Notifications
You must be signed in to change notification settings - Fork 24
Fix threadpool shifting for futureToAsync #209
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
Conversation
f04b610 to
c66f203
Compare
Codecov Report
@@ Coverage Diff @@
## master #209 +/- ##
==========================================
- Coverage 93.98% 93.33% -0.66%
==========================================
Files 5 5
Lines 133 135 +2
Branches 3 3
==========================================
+ Hits 125 126 +1
- Misses 8 9 +1
Continue to review full report at Codecov.
|
|
@felixbr Thanks for taking this on! This library has been needing to do some catch-up with cats-effect for a long time, and I'm not using Finagle these days, so it's hard for me to prioritize. Any chance you'd want to join as a maintainer? |
|
I'd be happy to join as a maintainer 🙂 |
|
After thinking about it a bit more, I think we should go the same route as I really hope downstream users will not ignore the deprecation, though 😶 |
|
@felixbr That sounds reasonable to me. |
c66f203 to
05cc6a0
Compare
|
I dug deeper and it seems that we cannot really fix this properly without putting a I also looked at So, what does this mean now? I'm keeping the additional function as I'm currently not sure what to do about the I'm thinking about tackling the implementation of |
3912677 to
3a8baec
Compare
3a8baec to
99b6ebe
Compare
|
The codecov tool seems to bug out again. It claims I haven't tested Anyway, I'd like to merge this soon, as I have implementations for |
|
It looks like coverage is complaining about My general approach to coverage is to have pretty low thresholds for "failing" checks but to merge anyway if I'm aware of what I'm doing. I'm happy to adjust the thresholds instead if you'd prefer. In any case, I'll merge this today if that's okay with you! |
|
I guess I'm not used to reading the coverage reports yet. In the "Files" windows it shows it differently, but the "Diff" is much clearer. 🙂 I'd be fine with merging as is. |
|
Great, thanks again! |
Don't merge this yet, I don't consider this done 🙂
Hi, I was using
catbird-effectto wrapfinagle-httpfor usage in projects that mainly usecats.effect.IOormonix.eval.Task.When I tried a few things locally I noticed in the log output that my logs (wrapped in
IO) where coming from thefinagle/nettythreadpool and not the main one even though the actual http-call was already done.After some testing and research I came to the conclusion that
io.catbird.util.effect.futureToAsyncis flawed and does only convertFuturetoIObut does not shift execution back to the threadpool initially used forIO.I wrote two tests for that (one negative and one positive) so you can easily see the difference and how a solution would look like.
The PR right now adds an additional function
futureToAsyncAndShiftinstead of changing the behavior of the existing one.However, I strongly think that this is a bad solution as the default should be safe and the current behavior is almost never what users want in practice.
I also looked into how
IO.fromFutureis implemented for Scala futures and indeed it shifts back to the IO threadpool after theFutureis resolved. (https://github.com/typelevel/cats-effect/blob/master/core/shared/src/main/scala/cats/effect/IO.scala#L1350-L1355)Imo this fix would warrant a breaking change (requiring a
ContextShift[F]in addition toAsync[F]) but I don't know what compatibility guarantees you want to provide. I'll rework the PR as needed in any case 🙂Cheers
~ Felix
edit: I also found cases where the execution did continue on the
IOpool even without my fix. This makes the current implementation even more wacky as the user has no deterministic control over what pool is being used. So even if we keepfutureToAsyncin its current form, we should make sure that it has deterministic and documented behavior regarding threadpools.