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

Replace low level forkIO with a safer alternative #2806

Closed
janmasrovira opened this issue Jun 6, 2024 · 0 comments · Fixed by #2809
Closed

Replace low level forkIO with a safer alternative #2806

janmasrovira opened this issue Jun 6, 2024 · 0 comments · Fixed by #2809
Assignees

Comments

@janmasrovira
Copy link
Collaborator

using forkIO is not recommended because:

async's high-level API spawns lexically scoped threads, ensuring the following key poperties that make it safer to use than using plain forkIO:

  • No exception is swallowed (waiting for results propagates exceptions).
  • No thread is leaked (left running unintentionally).

Recently we've observed some infinite loops when one of the threads was crashing and I suspect this could fix that issue. I don't have a concrete example to share.

@janmasrovira janmasrovira self-assigned this Jun 6, 2024
lukaszcz pushed a commit that referenced this issue Jun 7, 2024
- Closes #2806 

Now we properly wait for the log and worker threads to finish instead of
keeping them alive until the main thread dies.

Also, because we are now using
[`replicateConcurrently_`](https://hackage.haskell.org/package/effectful-2.3.0.0/docs/Effectful-Concurrent-Async.html#v:replicateConcurrently)
from `async`, any exception in a worker thread should be properly
propagated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant