[Haskell-cafe] Help with async library and killing child processes

Michael Hull mikehulluk at gmail.com
Thu Mar 19 14:40:02 UTC 2020


Hi Niklas and Patrick,

Thankyou both for the comments -- this is what I am looking for.

I have a follow-on question, if I have code like

getPages :: IO()
getPages = do (page1, page2, page3)
     <- runConcurrently $ (,,)
     <$> Concurrently (getURL "url1")
     <*> Concurrently (getURL "url2")
     <*> Concurrently (getURL "url3")

main :: IO()
main = do
    f <- async getPages
    cancel f

Am I guaranteed the the getURL() calls will definitely have either
finished, or cancel? (I looked through the source (
https://hackage.haskell.org/package/async-2.2.2/docs/src/Control.Concurrent.Async.html#Concurrently),
and I think so, because runConcurrently is implemented in terms of race,
which is implemented using withAsync, but I'm not confident with
interpreting Haskell!)


Many thanks,

Mike



On Wed, 18 Mar 2020 at 03:15, Niklas Hambüchen <mail at nh2.me> wrote:

> I've you're new to async, also check out my recent rework of the docs that
> talk about this topic specifically:
>
> https://github.com/simonmar/async/pull/105/files
>
> (To be available in the next release of async.)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20200319/dc85b757/attachment.html>


More information about the Haskell-Cafe mailing list