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

mapConcurrently and mapConcurrently_ behave differently than corresponding functions in the async library #117

Open
torgeirsh opened this issue Dec 7, 2023 · 0 comments

Comments

@torgeirsh
Copy link

Consider this simple test:

import qualified Control.Concurrent.Async as Async
import qualified Control.Exception as Exception
import qualified UnliftIO.Async as UnliftIO

main :: IO ()
main = UnliftIO.mapConcurrently_ (forever . print) ("01234" <> undefined :: [Char]) `Exception.finally` putStrLn "Finished"

The expectation is that the threads spawned by mapConcurrently_ are terminated before "Finished" is printed, but this is the output:

$ ./utest
Finished!
'3'
'4'
'0'
'1'
'2'
utest: Prelude.undefined
CallStack (from HasCallStack):
  undefined, called at utest/Main.hs:9:64 in main:Main
'3'
'4'

Replacing "UnliftIO.mapConcurrently_" with "Async.mapConcurrently_", I get the expected output:

$ ./result/bin/log-performance-test 
'1'
'0'
Finished!
utest: Prelude.undefined
CallStack (from HasCallStack):
  undefined, called at utest/Main.hs:9:61 in main:Main

The mapConcurrently (without _) function has similar differences. The test was run on Ubuntu Linux 23.10 with GHC 9.4.8, async 2.2.4, and unliftio 0.2.25.0.

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

No branches or pull requests

1 participant