{"action":"created","comment":{"url":"https://api.github.com/repos/haskell/cabal/pulls/comments/72307312","id":72307312,"diff_hunk":"@@ -186,6 +197,61 @@ downloadIndex transport verbosity remoteRepo cacheDir = do\n \n \n -- ------------------------------------------------------------\n+-- * Async fetch wrapper utilities\n+-- ------------------------------------------------------------\n+\n+type AsyncFetchMap = Map UnresolvedPkgLoc\n+                         (MVar (Either SomeException ResolvedPkgLoc))\n+\n+-- | Fork off an async action to download the given packages (by location).\n+--\n+-- The downloads are initiated in order, so you can arrange for packages that\n+-- will likely be needed sooner to be earlier in the list.\n+--\n+-- The body action is passed a map from those packages (identified by their\n+-- location) to a completion var for that package. So the body action should\n+-- lookup the location and use 'asyncFetchPackage' to get the result.\n+--\n+asyncFetchPackages :: Verbosity\n+                   -> RepoContext\n+                   -> [UnresolvedPkgLoc]\n+                   -> (AsyncFetchMap -> IO a)\n+                   -> IO a\n+asyncFetchPackages verbosity repoCtxt pkglocs body = do\n+    --TODO: [nice to have] use parallel downloads?\n+\n+    asyncDownloadVars <- sequence [ do v <- newEmptyMVar\n+                                       return (pkgloc, v)\n+                                  | pkgloc <- pkglocs ]\n+\n+    let fetchPackages :: IO ()\n+        fetchPackages =\n+          forM_ asyncDownloadVars $ \\(pkgloc, var) -> do\n+            result <- try $ fetchPackage verbosity repoCtxt pkgloc\n+            putMVar var result","path":"cabal-install/Distribution/Client/FetchUtils.hs","position":69,"original_position":69,"commit_id":"04eb17344777722653f595f11a81dacab13632dc","original_commit_id":"04eb17344777722653f595f11a81dacab13632dc","user":{"login":"dcoutts","id":1339423,"avatar_url":"https://avatars.githubusercontent.com/u/1339423?v=3","gravatar_id":"","url":"https://api.github.com/users/dcoutts","html_url":"https://github.com/dcoutts","followers_url":"https://api.github.com/users/dcoutts/followers","following_url":"https://api.github.com/users/dcoutts/following{/other_user}","gists_url":"https://api.github.com/users/dcoutts/gists{/gist_id}","starred_url":"https://api.github.com/users/dcoutts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcoutts/subscriptions","organizations_url":"https://api.github.com/users/dcoutts/orgs","repos_url":"https://api.github.com/users/dcoutts/repos","events_url":"https://api.github.com/users/dcoutts/events{/privacy}","received_events_url":"https://api.github.com/users/dcoutts/received_events","type":"User","site_admin":false},"body":"This is the crucial bit really, for fixing exception handling. Previously the exception was propagated locally in the async action and so the callers picking up the async fetch package results would wait forever (or rather get an MVar deadlock exception).","created_at":"2016-07-26T18:20:14Z","updated_at":"2016-07-26T18:20:14Z","html_url":"https://github.com/haskell/cabal/pull/3630#discussion_r72307312","pull_request_url":"https://api.github.com/repos/haskell/cabal/pulls/3630","_links":{"self":{"href":"https://api.github.com/repos/haskell/cabal/pulls/comments/72307312"},"html":{"href":"https://github.com/haskell/cabal/pull/3630#discussion_r72307312"},"pull_request":{"href":"https://api.github.com/repos/haskell/cabal/pulls/3630"}}},"pull_request":{"url":"https://api.github.com/repos/haskell/cabal/pulls/3630","id":78895170,"html_url":"https://github.com/haskell/cabal/pull/3630","diff_url":"https://github.com/haskell/cabal/pull/3630.diff","patch_url":"https://github.com/haskell/cabal/pull/3630.patch","issue_url":"https://api.github.com/repos/haskell/cabal/issues/3630","number":3630,"state":"open","locked":false,"title":"fix exception handling of downloads in new-build","user":{"login":"dcoutts","id":1339423,"avatar_url":"https://avatars.githubusercontent.com/u/1339423?v=3","gravatar_id":"","url":"https://api.github.com/users/dcoutts","html_url":"https://github.com/dcoutts","followers_url":"https://api.github.com/users/dcoutts/followers","following_url":"https://api.github.com/users/dcoutts/following{/other_user}","gists_url":"https://api.github.com/users/dcoutts/gists{/gist_id}","starred_url":"https://api.github.com/users/dcoutts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcoutts/subscriptions","organizations_url":"https://api.github.com/users/dcoutts/orgs","repos_url":"https://api.github.com/users/dcoutts/repos","events_url":"https://api.github.com/users/dcoutts/events{/privacy}","received_events_url":"https://api.github.com/users/dcoutts/received_events","type":"User","site_admin":false},"body":"Partly this is a continuation of the InstallPlan refactoring #3622, but also a related change to fix #3387, by handling exceptions during download properly.\r\n\r\nThese things are also a step towards finishing #3394 properly, since it means we now have all the `BuildResults` using proper exception types and so will be able to use that to report at the end what if anything when wrong.","created_at":"2016-07-26T17:48:26Z","updated_at":"2016-07-26T18:20:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b2c43620203e80d9acc501f05378d5ddce0959ce","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/haskell/cabal/pulls/3630/commits","review_comments_url":"https://api.github.com/repos/haskell/cabal/pulls/3630/comments","review_comment_url":"https://api.github.com/repos/haskell/cabal/pulls/comments{/number}","comments_url":"https://api.github.com/repos/haskell/cabal/issues/3630/comments","statuses_url":"https://api.github.com/repos/haskell/cabal/statuses/04eb17344777722653f595f11a81dacab13632dc","head":{"label":"dcoutts:new-build-exception-handling","ref":"new-build-exception-handling","sha":"04eb17344777722653f595f11a81dacab13632dc","user":{"login":"dcoutts","id":1339423,"avatar_url":"https://avatars.githubusercontent.com/u/1339423?v=3","gravatar_id":"","url":"https://api.github.com/users/dcoutts","html_url":"https://github.com/dcoutts","followers_url":"https://api.github.com/users/dcoutts/followers","following_url":"https://api.github.com/users/dcoutts/following{/other_user}","gists_url":"https://api.github.com/users/dcoutts/gists{/gist_id}","starred_url":"https://api.github.com/users/dcoutts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcoutts/subscriptions","organizations_url":"https://api.github.com/users/dcoutts/orgs","repos_url":"https://api.github.com/users/dcoutts/repos","events_url":"https://api.github.com/users/dcoutts/events{/privacy}","received_events_url":"https://api.github.com/users/dcoutts/received_events","type":"User","site_admin":false},"repo":{"id":10475196,"name":"cabal","full_name":"dcoutts/cabal","owner":{"login":"dcoutts","id":1339423,"avatar_url":"https://avatars.githubusercontent.com/u/1339423?v=3","gravatar_id":"","url":"https://api.github.com/users/dcoutts","html_url":"https://github.com/dcoutts","followers_url":"https://api.github.com/users/dcoutts/followers","following_url":"https://api.github.com/users/dcoutts/following{/other_user}","gists_url":"https://api.github.com/users/dcoutts/gists{/gist_id}","starred_url":"https://api.github.com/users/dcoutts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcoutts/subscriptions","organizations_url":"https://api.github.com/users/dcoutts/orgs","repos_url":"https://api.github.com/users/dcoutts/repos","events_url":"https://api.github.com/users/dcoutts/events{/privacy}","received_events_url":"https://api.github.com/users/dcoutts/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dcoutts/cabal","description":"Duncan's random Cabal hacking","fork":true,"url":"https://api.github.com/repos/dcoutts/cabal","forks_url":"https://api.github.com/repos/dcoutts/cabal/forks","keys_url":"https://api.github.com/repos/dcoutts/cabal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dcoutts/cabal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dcoutts/cabal/teams","hooks_url":"https://api.github.com/repos/dcoutts/cabal/hooks","issue_events_url":"https://api.github.com/repos/dcoutts/cabal/issues/events{/number}","events_url":"https://api.github.com/repos/dcoutts/cabal/events","assignees_url":"https://api.github.com/repos/dcoutts/cabal/assignees{/user}","branches_url":"https://api.github.com/repos/dcoutts/cabal/branches{/branch}","tags_url":"https://api.github.com/repos/dcoutts/cabal/tags","blobs_url":"https://api.github.com/repos/dcoutts/cabal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dcoutts/cabal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dcoutts/cabal/git/refs{/sha}","trees_url":"https://api.github.com/repos/dcoutts/cabal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dcoutts/cabal/statuses/{sha}","languages_url":"https://api.github.com/repos/dcoutts/cabal/languages","stargazers_url":"https://api.github.com/repos/dcoutts/cabal/stargazers","contributors_url":"https://api.github.com/repos/dcoutts/cabal/contributors","subscribers_url":"https://api.github.com/repos/dcoutts/cabal/subscribers","subscription_url":"https://api.github.com/repos/dcoutts/cabal/subscription","commits_url":"https://api.github.com/repos/dcoutts/cabal/commits{/sha}","git_commits_url":"https://api.github.com/repos/dcoutts/cabal/git/commits{/sha}","comments_url":"https://api.github.com/repos/dcoutts/cabal/comments{/number}","issue_comment_url":"https://api.github.com/repos/dcoutts/cabal/issues/comments{/number}","contents_url":"https://api.github.com/repos/dcoutts/cabal/contents/{+path}","compare_url":"https://api.github.com/repos/dcoutts/cabal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dcoutts/cabal/merges","archive_url":"https://api.github.com/repos/dcoutts/cabal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dcoutts/cabal/downloads","issues_url":"https://api.github.com/repos/dcoutts/cabal/issues{/number}","pulls_url":"https://api.github.com/repos/dcoutts/cabal/pulls{/number}","milestones_url":"https://api.github.com/repos/dcoutts/cabal/milestones{/number}","notifications_url":"https://api.github.com/repos/dcoutts/cabal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dcoutts/cabal/labels{/name}","releases_url":"https://api.github.com/repos/dcoutts/cabal/releases{/id}","deployments_url":"https://api.github.com/repos/dcoutts/cabal/deployments","created_at":"2013-06-04T09:31:49Z","updated_at":"2015-04-28T14:55:48Z","pushed_at":"2016-07-26T18:07:09Z","git_url":"git://github.com/dcoutts/cabal.git","ssh_url":"git@github.com:dcoutts/cabal.git","clone_url":"https://github.com/dcoutts/cabal.git","svn_url":"https://github.com/dcoutts/cabal","homepage":"http://haskell.org/cabal","size":29062,"stargazers_count":0,"watchers_count":0,"language":"Haskell","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"haskell:master","ref":"master","sha":"44f161792259b8af451f7a6de1b84d23930d0a63","user":{"login":"haskell","id":450574,"avatar_url":"https://avatars.githubusercontent.com/u/450574?v=3","gravatar_id":"","url":"https://api.github.com/users/haskell","html_url":"https://github.com/haskell","followers_url":"https://api.github.com/users/haskell/followers","following_url":"https://api.github.com/users/haskell/following{/other_user}","gists_url":"https://api.github.com/users/haskell/gists{/gist_id}","starred_url":"https://api.github.com/users/haskell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haskell/subscriptions","organizations_url":"https://api.github.com/users/haskell/orgs","repos_url":"https://api.github.com/users/haskell/repos","events_url":"https://api.github.com/users/haskell/events{/privacy}","received_events_url":"https://api.github.com/users/haskell/received_events","type":"Organization","site_admin":false},"repo":{"id":3728161,"name":"cabal","full_name":"haskell/cabal","owner":{"login":"haskell","id":450574,"avatar_url":"https://avatars.githubusercontent.com/u/450574?v=3","gravatar_id":"","url":"https://api.github.com/users/haskell","html_url":"https://github.com/haskell","followers_url":"https://api.github.com/users/haskell/followers","following_url":"https://api.github.com/users/haskell/following{/other_user}","gists_url":"https://api.github.com/users/haskell/gists{/gist_id}","starred_url":"https://api.github.com/users/haskell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haskell/subscriptions","organizations_url":"https://api.github.com/users/haskell/orgs","repos_url":"https://api.github.com/users/haskell/repos","events_url":"https://api.github.com/users/haskell/events{/privacy}","received_events_url":"https://api.github.com/users/haskell/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/haskell/cabal","description":"Official upstream development repository for Cabal and cabal-install","fork":false,"url":"https://api.github.com/repos/haskell/cabal","forks_url":"https://api.github.com/repos/haskell/cabal/forks","keys_url":"https://api.github.com/repos/haskell/cabal/keys{/key_id}","collaborators_url":"https://api.github.com/repos/haskell/cabal/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/haskell/cabal/teams","hooks_url":"https://api.github.com/repos/haskell/cabal/hooks","issue_events_url":"https://api.github.com/repos/haskell/cabal/issues/events{/number}","events_url":"https://api.github.com/repos/haskell/cabal/events","assignees_url":"https://api.github.com/repos/haskell/cabal/assignees{/user}","branches_url":"https://api.github.com/repos/haskell/cabal/branches{/branch}","tags_url":"https://api.github.com/repos/haskell/cabal/tags","blobs_url":"https://api.github.com/repos/haskell/cabal/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/haskell/cabal/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/haskell/cabal/git/refs{/sha}","trees_url":"https://api.github.com/repos/haskell/cabal/git/trees{/sha}","statuses_url":"https://api.github.com/repos/haskell/cabal/statuses/{sha}","languages_url":"https://api.github.com/repos/haskell/cabal/languages","stargazers_url":"https://api.github.com/repos/haskell/cabal/stargazers","contributors_url":"https://api.github.com/repos/haskell/cabal/contributors","subscribers_url":"https://api.github.com/repos/haskell/cabal/subscribers","subscription_url":"https://api.github.com/repos/haskell/cabal/subscription","commits_url":"https://api.github.com/repos/haskell/cabal/commits{/sha}","git_commits_url":"https://api.github.com/repos/haskell/cabal/git/commits{/sha}","comments_url":"https://api.github.com/repos/haskell/cabal/comments{/number}","issue_comment_url":"https://api.github.com/repos/haskell/cabal/issues/comments{/number}","contents_url":"https://api.github.com/repos/haskell/cabal/contents/{+path}","compare_url":"https://api.github.com/repos/haskell/cabal/compare/{base}...{head}","merges_url":"https://api.github.com/repos/haskell/cabal/merges","archive_url":"https://api.github.com/repos/haskell/cabal/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/haskell/cabal/downloads","issues_url":"https://api.github.com/repos/haskell/cabal/issues{/number}","pulls_url":"https://api.github.com/repos/haskell/cabal/pulls{/number}","milestones_url":"https://api.github.com/repos/haskell/cabal/milestones{/number}","notifications_url":"https://api.github.com/repos/haskell/cabal/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/haskell/cabal/labels{/name}","releases_url":"https://api.github.com/repos/haskell/cabal/releases{/id}","deployments_url":"https://api.github.com/repos/haskell/cabal/deployments","created_at":"2012-03-15T12:53:38Z","updated_at":"2016-07-25T00:08:03Z","pushed_at":"2016-07-26T18:19:28Z","git_url":"git://github.com/haskell/cabal.git","ssh_url":"git@github.com:haskell/cabal.git","clone_url":"https://github.com/haskell/cabal.git","svn_url":"https://github.com/haskell/cabal","homepage":"http://haskell.org/cabal","size":31087,"stargazers_count":623,"watchers_count":623,"language":"Haskell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":328,"mirror_url":null,"open_issues_count":737,"forks":328,"open_issues":737,"watchers":623,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/haskell/cabal/pulls/3630"},"html":{"href":"https://github.com/haskell/cabal/pull/3630"},"issue":{"href":"https://api.github.com/repos/haskell/cabal/issues/3630"},"comments":{"href":"https://api.github.com/repos/haskell/cabal/issues/3630/comments"},"review_comments":{"href":"https://api.github.com/repos/haskell/cabal/pulls/3630/comments"},"review_comment":{"href":"https://api.github.com/repos/haskell/cabal/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/haskell/cabal/pulls/3630/commits"},"statuses":{"href":"https://api.github.com/repos/haskell/cabal/statuses/04eb17344777722653f595f11a81dacab13632dc"}}}}
{"actor":{"display_login":"dcoutts"}}