{"action":"created","issue":{"url":"https://api.github.com/repos/apache/spark/issues/7385","labels_url":"https://api.github.com/repos/apache/spark/issues/7385/labels{/name}","comments_url":"https://api.github.com/repos/apache/spark/issues/7385/comments","events_url":"https://api.github.com/repos/apache/spark/issues/7385/events","html_url":"https://github.com/apache/spark/pull/7385","id":94855627,"number":7385,"title":"[SPARK-9026] Refactor SimpleFutureAction.onComplete to not launch separate thread for every callback","user":{"login":"JoshRosen","id":50748,"avatar_url":"https://avatars.githubusercontent.com/u/50748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshRosen","html_url":"https://github.com/JoshRosen","followers_url":"https://api.github.com/users/JoshRosen/followers","following_url":"https://api.github.com/users/JoshRosen/following{/other_user}","gists_url":"https://api.github.com/users/JoshRosen/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshRosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshRosen/subscriptions","organizations_url":"https://api.github.com/users/JoshRosen/orgs","repos_url":"https://api.github.com/users/JoshRosen/repos","events_url":"https://api.github.com/users/JoshRosen/events{/privacy}","received_events_url":"https://api.github.com/users/JoshRosen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":88,"created_at":"2015-07-14T02:47:56Z","updated_at":"2015-07-17T23:54:37Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/7385","html_url":"https://github.com/apache/spark/pull/7385","diff_url":"https://github.com/apache/spark/pull/7385.diff","patch_url":"https://github.com/apache/spark/pull/7385.patch"},"body":"This commit refactors SimpleFutureAction so that registering a callback with `onComplete` does not immediately tie up a thread in the provided execution context.\r\n\r\nAs @zsxwing noticed in https://github.com/apache/spark/pull/7276#issuecomment-121097747, the existing implementation of SimpleFutureAction.onComplete creates a separate thread to wrap the blocking `awaitResult()` callback:\r\n\r\n```scala\r\n  override def onComplete[U](func: (Try[T]) => U)(implicit executor: ExecutionContext) {\r\n    executor.execute(new Runnable {\r\n      override def run() {\r\n        func(awaitResult())\r\n      }\r\n    })\r\n  }\r\n```\r\n\r\nThis PR addresses this issue by making JobWaiter into a Future using that future in the implementation of SimpleFutureAction's future methods.\r\n\r\nThis patch was pair-programmed with @tdas."},"comment":{"url":"https://api.github.com/repos/apache/spark/issues/comments/122457472","html_url":"https://github.com/apache/spark/pull/7385#issuecomment-122457472","issue_url":"https://api.github.com/repos/apache/spark/issues/7385","id":122457472,"user":{"login":"SparkQA","id":8108735,"avatar_url":"https://avatars.githubusercontent.com/u/8108735?v=3","gravatar_id":"","url":"https://api.github.com/users/SparkQA","html_url":"https://github.com/SparkQA","followers_url":"https://api.github.com/users/SparkQA/followers","following_url":"https://api.github.com/users/SparkQA/following{/other_user}","gists_url":"https://api.github.com/users/SparkQA/gists{/gist_id}","starred_url":"https://api.github.com/users/SparkQA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SparkQA/subscriptions","organizations_url":"https://api.github.com/users/SparkQA/orgs","repos_url":"https://api.github.com/users/SparkQA/repos","events_url":"https://api.github.com/users/SparkQA/events{/privacy}","received_events_url":"https://api.github.com/users/SparkQA/received_events","type":"User","site_admin":false},"created_at":"2015-07-17T23:54:37Z","updated_at":"2015-07-17T23:54:37Z","body":"  [Test build #37673 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/37673/console) for   PR 7385 at commit [`1a19268`](https://github.com/apache/spark/commit/1a19268fda972f6103bcd50f376c0f57a238b394).\n * This patch **fails Spark unit tests**.\n * This patch merges cleanly.\n * This patch adds no public classes."}}