{"action":"created","comment":{"url":"https://api.github.com/repos/dask/distributed/pulls/comments/87692592","pull_request_review_id":8297966,"id":87692592,"diff_hunk":"@@ -158,22 +158,36 @@ def add_done_callback(self, fn):\n         The callback ``fn`` should take the future as its only argument.  This\n         will be called regardless of if the future completes successfully,\n         errs, or is cancelled\n+\n+        The callback is executed in a separate thread.\n         \"\"\"\n-        self.client.loop.add_callback(done_callback, self, fn)\n+        cls = Future\n+        if cls._cb_executor is None or cls._cb_executor_pid != os.getpid():\n+            cls._cb_executor = ThreadPoolExecutor(1)\n+            cls._cb_executor_pid = os.getpid()","path":"distributed/client.py","position":112,"original_position":112,"commit_id":"1c0ad91512a8e603d7bc4373646d6d5b9827f1c3","original_commit_id":"1c0ad91512a8e603d7bc4373646d6d5b9827f1c3","user":{"login":"mrocklin","id":306380,"avatar_url":"https://avatars.githubusercontent.com/u/306380?v=3","gravatar_id":"","url":"https://api.github.com/users/mrocklin","html_url":"https://github.com/mrocklin","followers_url":"https://api.github.com/users/mrocklin/followers","following_url":"https://api.github.com/users/mrocklin/following{/other_user}","gists_url":"https://api.github.com/users/mrocklin/gists{/gist_id}","starred_url":"https://api.github.com/users/mrocklin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mrocklin/subscriptions","organizations_url":"https://api.github.com/users/mrocklin/orgs","repos_url":"https://api.github.com/users/mrocklin/repos","events_url":"https://api.github.com/users/mrocklin/events{/privacy}","received_events_url":"https://api.github.com/users/mrocklin/received_events","type":"User","site_admin":false},"body":"The PID checking here is in case we fork a process that has Futures?  ","created_at":"2016-11-12T13:12:14Z","updated_at":"2016-11-12T13:20:00Z","html_url":"https://github.com/dask/distributed/pull/656#discussion_r87692592","pull_request_url":"https://api.github.com/repos/dask/distributed/pulls/656","_links":{"self":{"href":"https://api.github.com/repos/dask/distributed/pulls/comments/87692592"},"html":{"href":"https://github.com/dask/distributed/pull/656#discussion_r87692592"},"pull_request":{"href":"https://api.github.com/repos/dask/distributed/pulls/656"}}},"pull_request":{"url":"https://api.github.com/repos/dask/distributed/pulls/656","id":93436189,"html_url":"https://github.com/dask/distributed/pull/656","diff_url":"https://github.com/dask/distributed/pull/656.diff","patch_url":"https://github.com/dask/distributed/pull/656.patch","issue_url":"https://api.github.com/repos/dask/distributed/issues/656","number":656,"state":"open","locked":false,"title":"Execute a Future's done callback in a separate thread","user":{"login":"pitrou","id":1721820,"avatar_url":"https://avatars.githubusercontent.com/u/1721820?v=3","gravatar_id":"","url":"https://api.github.com/users/pitrou","html_url":"https://github.com/pitrou","followers_url":"https://api.github.com/users/pitrou/followers","following_url":"https://api.github.com/users/pitrou/following{/other_user}","gists_url":"https://api.github.com/users/pitrou/gists{/gist_id}","starred_url":"https://api.github.com/users/pitrou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pitrou/subscriptions","organizations_url":"https://api.github.com/users/pitrou/orgs","repos_url":"https://api.github.com/users/pitrou/repos","events_url":"https://api.github.com/users/pitrou/events{/privacy}","received_events_url":"https://api.github.com/users/pitrou/received_events","type":"User","site_admin":false},"body":"Fixes #647.","created_at":"2016-11-12T11:21:41Z","updated_at":"2016-11-12T13:20:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bc299785cf43c78bdfc033fb87f1ab435acffca8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/dask/distributed/pulls/656/commits","review_comments_url":"https://api.github.com/repos/dask/distributed/pulls/656/comments","review_comment_url":"https://api.github.com/repos/dask/distributed/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dask/distributed/issues/656/comments","statuses_url":"https://api.github.com/repos/dask/distributed/statuses/1c0ad91512a8e603d7bc4373646d6d5b9827f1c3","head":{"label":"pitrou:done_callback_thread","ref":"done_callback_thread","sha":"1c0ad91512a8e603d7bc4373646d6d5b9827f1c3","user":{"login":"pitrou","id":1721820,"avatar_url":"https://avatars.githubusercontent.com/u/1721820?v=3","gravatar_id":"","url":"https://api.github.com/users/pitrou","html_url":"https://github.com/pitrou","followers_url":"https://api.github.com/users/pitrou/followers","following_url":"https://api.github.com/users/pitrou/following{/other_user}","gists_url":"https://api.github.com/users/pitrou/gists{/gist_id}","starred_url":"https://api.github.com/users/pitrou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pitrou/subscriptions","organizations_url":"https://api.github.com/users/pitrou/orgs","repos_url":"https://api.github.com/users/pitrou/repos","events_url":"https://api.github.com/users/pitrou/events{/privacy}","received_events_url":"https://api.github.com/users/pitrou/received_events","type":"User","site_admin":false},"repo":{"id":70810384,"name":"distributed","full_name":"pitrou/distributed","owner":{"login":"pitrou","id":1721820,"avatar_url":"https://avatars.githubusercontent.com/u/1721820?v=3","gravatar_id":"","url":"https://api.github.com/users/pitrou","html_url":"https://github.com/pitrou","followers_url":"https://api.github.com/users/pitrou/followers","following_url":"https://api.github.com/users/pitrou/following{/other_user}","gists_url":"https://api.github.com/users/pitrou/gists{/gist_id}","starred_url":"https://api.github.com/users/pitrou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pitrou/subscriptions","organizations_url":"https://api.github.com/users/pitrou/orgs","repos_url":"https://api.github.com/users/pitrou/repos","events_url":"https://api.github.com/users/pitrou/events{/privacy}","received_events_url":"https://api.github.com/users/pitrou/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pitrou/distributed","description":"Distributed computation in Python","fork":true,"url":"https://api.github.com/repos/pitrou/distributed","forks_url":"https://api.github.com/repos/pitrou/distributed/forks","keys_url":"https://api.github.com/repos/pitrou/distributed/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pitrou/distributed/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pitrou/distributed/teams","hooks_url":"https://api.github.com/repos/pitrou/distributed/hooks","issue_events_url":"https://api.github.com/repos/pitrou/distributed/issues/events{/number}","events_url":"https://api.github.com/repos/pitrou/distributed/events","assignees_url":"https://api.github.com/repos/pitrou/distributed/assignees{/user}","branches_url":"https://api.github.com/repos/pitrou/distributed/branches{/branch}","tags_url":"https://api.github.com/repos/pitrou/distributed/tags","blobs_url":"https://api.github.com/repos/pitrou/distributed/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pitrou/distributed/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pitrou/distributed/git/refs{/sha}","trees_url":"https://api.github.com/repos/pitrou/distributed/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pitrou/distributed/statuses/{sha}","languages_url":"https://api.github.com/repos/pitrou/distributed/languages","stargazers_url":"https://api.github.com/repos/pitrou/distributed/stargazers","contributors_url":"https://api.github.com/repos/pitrou/distributed/contributors","subscribers_url":"https://api.github.com/repos/pitrou/distributed/subscribers","subscription_url":"https://api.github.com/repos/pitrou/distributed/subscription","commits_url":"https://api.github.com/repos/pitrou/distributed/commits{/sha}","git_commits_url":"https://api.github.com/repos/pitrou/distributed/git/commits{/sha}","comments_url":"https://api.github.com/repos/pitrou/distributed/comments{/number}","issue_comment_url":"https://api.github.com/repos/pitrou/distributed/issues/comments{/number}","contents_url":"https://api.github.com/repos/pitrou/distributed/contents/{+path}","compare_url":"https://api.github.com/repos/pitrou/distributed/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pitrou/distributed/merges","archive_url":"https://api.github.com/repos/pitrou/distributed/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pitrou/distributed/downloads","issues_url":"https://api.github.com/repos/pitrou/distributed/issues{/number}","pulls_url":"https://api.github.com/repos/pitrou/distributed/pulls{/number}","milestones_url":"https://api.github.com/repos/pitrou/distributed/milestones{/number}","notifications_url":"https://api.github.com/repos/pitrou/distributed/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pitrou/distributed/labels{/name}","releases_url":"https://api.github.com/repos/pitrou/distributed/releases{/id}","deployments_url":"https://api.github.com/repos/pitrou/distributed/deployments","created_at":"2016-10-13T13:39:52Z","updated_at":"2016-10-13T13:39:54Z","pushed_at":"2016-11-12T11:44:31Z","git_url":"git://github.com/pitrou/distributed.git","ssh_url":"git@github.com:pitrou/distributed.git","clone_url":"https://github.com/pitrou/distributed.git","svn_url":"https://github.com/pitrou/distributed","homepage":"http://distributed.readthedocs.io/en/latest/","size":3684,"stargazers_count":0,"watchers_count":0,"language":"Python","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":"dask:master","ref":"master","sha":"fcf5fa4adede93ac5051bbd4275f0878a0a273ed","user":{"login":"dask","id":17131925,"avatar_url":"https://avatars.githubusercontent.com/u/17131925?v=3","gravatar_id":"","url":"https://api.github.com/users/dask","html_url":"https://github.com/dask","followers_url":"https://api.github.com/users/dask/followers","following_url":"https://api.github.com/users/dask/following{/other_user}","gists_url":"https://api.github.com/users/dask/gists{/gist_id}","starred_url":"https://api.github.com/users/dask/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dask/subscriptions","organizations_url":"https://api.github.com/users/dask/orgs","repos_url":"https://api.github.com/users/dask/repos","events_url":"https://api.github.com/users/dask/events{/privacy}","received_events_url":"https://api.github.com/users/dask/received_events","type":"Organization","site_admin":false},"repo":{"id":42408083,"name":"distributed","full_name":"dask/distributed","owner":{"login":"dask","id":17131925,"avatar_url":"https://avatars.githubusercontent.com/u/17131925?v=3","gravatar_id":"","url":"https://api.github.com/users/dask","html_url":"https://github.com/dask","followers_url":"https://api.github.com/users/dask/followers","following_url":"https://api.github.com/users/dask/following{/other_user}","gists_url":"https://api.github.com/users/dask/gists{/gist_id}","starred_url":"https://api.github.com/users/dask/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dask/subscriptions","organizations_url":"https://api.github.com/users/dask/orgs","repos_url":"https://api.github.com/users/dask/repos","events_url":"https://api.github.com/users/dask/events{/privacy}","received_events_url":"https://api.github.com/users/dask/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dask/distributed","description":"Distributed computation in Python","fork":false,"url":"https://api.github.com/repos/dask/distributed","forks_url":"https://api.github.com/repos/dask/distributed/forks","keys_url":"https://api.github.com/repos/dask/distributed/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dask/distributed/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dask/distributed/teams","hooks_url":"https://api.github.com/repos/dask/distributed/hooks","issue_events_url":"https://api.github.com/repos/dask/distributed/issues/events{/number}","events_url":"https://api.github.com/repos/dask/distributed/events","assignees_url":"https://api.github.com/repos/dask/distributed/assignees{/user}","branches_url":"https://api.github.com/repos/dask/distributed/branches{/branch}","tags_url":"https://api.github.com/repos/dask/distributed/tags","blobs_url":"https://api.github.com/repos/dask/distributed/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dask/distributed/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dask/distributed/git/refs{/sha}","trees_url":"https://api.github.com/repos/dask/distributed/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dask/distributed/statuses/{sha}","languages_url":"https://api.github.com/repos/dask/distributed/languages","stargazers_url":"https://api.github.com/repos/dask/distributed/stargazers","contributors_url":"https://api.github.com/repos/dask/distributed/contributors","subscribers_url":"https://api.github.com/repos/dask/distributed/subscribers","subscription_url":"https://api.github.com/repos/dask/distributed/subscription","commits_url":"https://api.github.com/repos/dask/distributed/commits{/sha}","git_commits_url":"https://api.github.com/repos/dask/distributed/git/commits{/sha}","comments_url":"https://api.github.com/repos/dask/distributed/comments{/number}","issue_comment_url":"https://api.github.com/repos/dask/distributed/issues/comments{/number}","contents_url":"https://api.github.com/repos/dask/distributed/contents/{+path}","compare_url":"https://api.github.com/repos/dask/distributed/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dask/distributed/merges","archive_url":"https://api.github.com/repos/dask/distributed/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dask/distributed/downloads","issues_url":"https://api.github.com/repos/dask/distributed/issues{/number}","pulls_url":"https://api.github.com/repos/dask/distributed/pulls{/number}","milestones_url":"https://api.github.com/repos/dask/distributed/milestones{/number}","notifications_url":"https://api.github.com/repos/dask/distributed/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dask/distributed/labels{/name}","releases_url":"https://api.github.com/repos/dask/distributed/releases{/id}","deployments_url":"https://api.github.com/repos/dask/distributed/deployments","created_at":"2015-09-13T18:42:29Z","updated_at":"2016-11-10T12:53:36Z","pushed_at":"2016-11-12T11:44:31Z","git_url":"git://github.com/dask/distributed.git","ssh_url":"git@github.com:dask/distributed.git","clone_url":"https://github.com/dask/distributed.git","svn_url":"https://github.com/dask/distributed","homepage":"http://distributed.readthedocs.io/en/latest/","size":4115,"stargazers_count":172,"watchers_count":172,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":73,"mirror_url":null,"open_issues_count":63,"forks":73,"open_issues":63,"watchers":172,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dask/distributed/pulls/656"},"html":{"href":"https://github.com/dask/distributed/pull/656"},"issue":{"href":"https://api.github.com/repos/dask/distributed/issues/656"},"comments":{"href":"https://api.github.com/repos/dask/distributed/issues/656/comments"},"review_comments":{"href":"https://api.github.com/repos/dask/distributed/pulls/656/comments"},"review_comment":{"href":"https://api.github.com/repos/dask/distributed/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dask/distributed/pulls/656/commits"},"statuses":{"href":"https://api.github.com/repos/dask/distributed/statuses/1c0ad91512a8e603d7bc4373646d6d5b9827f1c3"}}}}
{"actor":{"display_login":"mrocklin"}}