Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@adamgfraser
Copy link
Contributor

Resolves #3940.

The issue is that in our optimized implementation of foreachPar_ we are forking a fiber for each task and waiting for it to signal success or failure. But if an exception is thrown during the construction of the task this logic is never executed so we suspend indefinitely waiting for the signal.

This PR addresses by using effectSuspendTotal to convert thrown exceptions in constructing the task to fiber failures.

One slightly unfortunate thing is that now there is a slight asymmetry between foreach and foreachPar in that ZIO.foreach(as)(f).run will fail with a fiber failure if f throwsbutZIO.foreachPar(as)(f).run` will return an exit with a die failure..

@adamgfraser adamgfraser merged commit d18521e into zio:master Jul 15, 2020
@adamgfraser adamgfraser deleted the 3940 branch July 27, 2020 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with Handling of Uncaught Exceptions in Parallel Code

3 participants