About fibers and cancellation #4181
-
Hi 👋, I have 3 questions about fibers and cancellation in cats effect:
Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I would still say that
Even if the fiber is finite and short-lived, it may acquire resources or have some finalizers. If the application (gracefully) shuts down, those finalizers will not be run. In general, you should prefer
A fiber can self cancel via
Depends what "unexpectedly" means exactly :) no, a fiber will not spontaneously
Note, the only fiber that is directly canceled by
No, I would say that's not correct. The benefit is that the finalizers of those fibers (e.g. flushing files, releasing resources, gracefully closing connections) are guaranteed to be called when the app shuts down. If you just use |
Beta Was this translation helpful? Give feedback.
-
Adding a more succinct follow-on to @armanbilge's excellent answer…
However, inventing novel forms of concurrency is not something most end users need to worry about! Instead of doing this, tools like |
Beta Was this translation helpful? Give feedback.
I would still say that
start
is unsafe . If you keep a handle to the fiber, that doesn't magically makestart
safe, that just means that you are doing the extra work to manage the fact that it's unsafe :)Even if the fiber is finite and short-lived, it ma…