-
Notifications
You must be signed in to change notification settings - Fork 523
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
IORunLoop loops indefinitely after unsafeRunSync is called #326
Comments
IORunLoop
loops indefinitely after unsafeRunSync
is called
|
What if you write IO("success").foreverM.start.bracket(_ => IO.pure("success"))(_.cancel) |
What does
Not really, without any async or "cancel" boundaries inserted in such a loop, it isn't. I mean the background process that does the processing, not talking about the bind continuation of the result. Note that that |
Shouldn't it be with auto-cancellable binds? |
Yes, but that flag is checked only on async boundaries (e.g. stuff built with |
That is very surprising. I would expect that snippet to work. Otherwise what is the difference with non-auto-cancellable-binds? |
|
Common sense in this case is not reliable. Most people expect magic in the case of cancelation. Even if you take care of this case:
We need to draw lines and the line was currently drawn at async boundaries that we manage. |
Also, fix is easy:
|
I guess I'm unclear on what exactly constitutes an async boundary in this case. Having some
This is a good point
I don't buy into this argument in general, use |
Wouldn't it make sense to have |
I'm actually expecting these to work, the snippet above can't really be made to work without fairness (e.g. Fibers being scheduled by the IO interpreter "manually" or with auto-shifting), since it never yields back control. I do think EDIT: well, without fairness it can be made to work with best-effort guarantees, but not anything stronger than that |
Everything that gets created via And obviously anything that involves a
Yes, that's cancelable.
Yes, that's cancelable.
Maybe, I've gone back and forth on it myself. I don't think there are many cases in which it is needed — besides the never ending, synchronous loops which frankly I haven't seen much in actual code. But it does well in demos that calculate Fibonacci 🙂 If we decide on it, it will have to wait for 2.0 though. 1.0.0 is next Monday and this is not the kind of emergency that can delay it. |
@mpilquist your snippets has the same issues as mine. |
@alexandru I actually agree with you 100% I saw the snippet and I unconsciously mapped it to things that actually do have an async boundary, without realising that that's the key thing that makes this behaviour happen. |
Seems like this section is out of date and could use refactoring before release to avoid confusion |
The following snippet of code after is being run continues to utilize 1 cpu (100% usage):
As other have pointed out in gitter,
IO("success")
is not cancelable, butIO("success").foreverM
should be.I profiled the application (run inside
sbt test
) with yourkit and this is the relevant part:The text was updated successfully, but these errors were encountered: