{"action":"created","comment":{"url":"https://api.github.com/repos/python/asyncio/pulls/comments/40746931","id":40746931,"diff_hunk":"@@ -360,25 +360,6 @@ def set_exception(self, exception):\n \n     # Truly internal methods.","path":"asyncio/futures.py","position":11,"original_position":11,"commit_id":"59a0c3c6c5f47ab21212268fe8a127a0d4b320ce","original_commit_id":"59a0c3c6c5f47ab21212268fe8a127a0d4b320ce","user":{"login":"gvanrossum","id":2894642,"avatar_url":"https://avatars.githubusercontent.com/u/2894642?v=3","gravatar_id":"","url":"https://api.github.com/users/gvanrossum","html_url":"https://github.com/gvanrossum","followers_url":"https://api.github.com/users/gvanrossum/followers","following_url":"https://api.github.com/users/gvanrossum/following{/other_user}","gists_url":"https://api.github.com/users/gvanrossum/gists{/gist_id}","starred_url":"https://api.github.com/users/gvanrossum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gvanrossum/subscriptions","organizations_url":"https://api.github.com/users/gvanrossum/orgs","repos_url":"https://api.github.com/users/gvanrossum/repos","events_url":"https://api.github.com/users/gvanrossum/events{/privacy}","received_events_url":"https://api.github.com/users/gvanrossum/received_events","type":"User","site_admin":false},"body":"This comment is obsolete; just delete it.","created_at":"2015-09-30T00:16:59Z","updated_at":"2015-09-30T00:16:59Z","html_url":"https://github.com/python/asyncio/pull/273#discussion_r40746931","pull_request_url":"https://api.github.com/repos/python/asyncio/pulls/273","_links":{"self":{"href":"https://api.github.com/repos/python/asyncio/pulls/comments/40746931"},"html":{"href":"https://github.com/python/asyncio/pull/273#discussion_r40746931"},"pull_request":{"href":"https://api.github.com/repos/python/asyncio/pulls/273"}}},"pull_request":{"url":"https://api.github.com/repos/python/asyncio/pulls/273","id":46155888,"html_url":"https://github.com/python/asyncio/pull/273","diff_url":"https://github.com/python/asyncio/pull/273.diff","patch_url":"https://github.com/python/asyncio/pull/273.patch","issue_url":"https://api.github.com/repos/python/asyncio/issues/273","number":273,"state":"open","locked":false,"title":"Submitting a coroutine to an asyncio event loop","user":{"login":"vxgmichel","id":7490006,"avatar_url":"https://avatars.githubusercontent.com/u/7490006?v=3","gravatar_id":"","url":"https://api.github.com/users/vxgmichel","html_url":"https://github.com/vxgmichel","followers_url":"https://api.github.com/users/vxgmichel/followers","following_url":"https://api.github.com/users/vxgmichel/following{/other_user}","gists_url":"https://api.github.com/users/vxgmichel/gists{/gist_id}","starred_url":"https://api.github.com/users/vxgmichel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vxgmichel/subscriptions","organizations_url":"https://api.github.com/users/vxgmichel/orgs","repos_url":"https://api.github.com/users/vxgmichel/repos","events_url":"https://api.github.com/users/vxgmichel/events{/privacy}","received_events_url":"https://api.github.com/users/vxgmichel/received_events","type":"User","site_admin":false},"body":"This PR follows up on this [conversation](https://mail.python.org/pipermail/python-ideas/2015-September/036512.html) on the python-ideas mailing list. It is based on the implementation I posted and commented [here](https://github.com/vxgmichel/asyncio-loopexecutor), but discarding the executor.\r\n\r\nThis PR includes:\r\n- a `connect_futures` function, to safely connect two futures regardless of their types\r\n- a `submit_to_loop` function, to submit a coroutine from a thread to a given event loop\r\n- a test case for `submit_to_loop` (runs in about 15 ms)\r\n\r\nIt also affects `wrap_future`, refactored to use `connect_futures` and avoid code duplication.\r\n\r\nI tried to gather my changes as much as possible. However, you might want to have a look at:\r\n- `import asyncio` (in futures.py). I needed `ensure_future` for `submit_in_loop` and couldn't import it with `from . import tasks` (because of circular import).\r\n- `_copy_state` (in futures.py). The code in `Future._copy_state` should probably move in `_copy_state` as I pointed out in a comment.\r\n- `_schedule` works exactly like `ensure_future` but adds an optional `destination` argument. There could be some refactoring here, though you probably don't want to change the `ensure_future` prototype.\r\n\r\nNew names and prototypes might also need to be rethought, along with docstrings and type testing. I'm not sure either about how to use the `TestLoop`, though the tests seem to pass properly.","created_at":"2015-09-28T13:24:17Z","updated_at":"2015-09-30T00:16:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"caab6c419595d52cca7c82e8f52bfdc43f9647b2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/python/asyncio/pulls/273/commits","review_comments_url":"https://api.github.com/repos/python/asyncio/pulls/273/comments","review_comment_url":"https://api.github.com/repos/python/asyncio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/python/asyncio/issues/273/comments","statuses_url":"https://api.github.com/repos/python/asyncio/statuses/59a0c3c6c5f47ab21212268fe8a127a0d4b320ce","head":{"label":"vxgmichel:submit-to-loop","ref":"submit-to-loop","sha":"59a0c3c6c5f47ab21212268fe8a127a0d4b320ce","user":{"login":"vxgmichel","id":7490006,"avatar_url":"https://avatars.githubusercontent.com/u/7490006?v=3","gravatar_id":"","url":"https://api.github.com/users/vxgmichel","html_url":"https://github.com/vxgmichel","followers_url":"https://api.github.com/users/vxgmichel/followers","following_url":"https://api.github.com/users/vxgmichel/following{/other_user}","gists_url":"https://api.github.com/users/vxgmichel/gists{/gist_id}","starred_url":"https://api.github.com/users/vxgmichel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vxgmichel/subscriptions","organizations_url":"https://api.github.com/users/vxgmichel/orgs","repos_url":"https://api.github.com/users/vxgmichel/repos","events_url":"https://api.github.com/users/vxgmichel/events{/privacy}","received_events_url":"https://api.github.com/users/vxgmichel/received_events","type":"User","site_admin":false},"repo":{"id":43287097,"name":"asyncio","full_name":"vxgmichel/asyncio","owner":{"login":"vxgmichel","id":7490006,"avatar_url":"https://avatars.githubusercontent.com/u/7490006?v=3","gravatar_id":"","url":"https://api.github.com/users/vxgmichel","html_url":"https://github.com/vxgmichel","followers_url":"https://api.github.com/users/vxgmichel/followers","following_url":"https://api.github.com/users/vxgmichel/following{/other_user}","gists_url":"https://api.github.com/users/vxgmichel/gists{/gist_id}","starred_url":"https://api.github.com/users/vxgmichel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vxgmichel/subscriptions","organizations_url":"https://api.github.com/users/vxgmichel/orgs","repos_url":"https://api.github.com/users/vxgmichel/repos","events_url":"https://api.github.com/users/vxgmichel/events{/privacy}","received_events_url":"https://api.github.com/users/vxgmichel/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vxgmichel/asyncio","description":"This project is the asyncio module for Python 3.3. Since Python 3.4, asyncio is part of the standard library.","fork":true,"url":"https://api.github.com/repos/vxgmichel/asyncio","forks_url":"https://api.github.com/repos/vxgmichel/asyncio/forks","keys_url":"https://api.github.com/repos/vxgmichel/asyncio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vxgmichel/asyncio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vxgmichel/asyncio/teams","hooks_url":"https://api.github.com/repos/vxgmichel/asyncio/hooks","issue_events_url":"https://api.github.com/repos/vxgmichel/asyncio/issues/events{/number}","events_url":"https://api.github.com/repos/vxgmichel/asyncio/events","assignees_url":"https://api.github.com/repos/vxgmichel/asyncio/assignees{/user}","branches_url":"https://api.github.com/repos/vxgmichel/asyncio/branches{/branch}","tags_url":"https://api.github.com/repos/vxgmichel/asyncio/tags","blobs_url":"https://api.github.com/repos/vxgmichel/asyncio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vxgmichel/asyncio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vxgmichel/asyncio/git/refs{/sha}","trees_url":"https://api.github.com/repos/vxgmichel/asyncio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vxgmichel/asyncio/statuses/{sha}","languages_url":"https://api.github.com/repos/vxgmichel/asyncio/languages","stargazers_url":"https://api.github.com/repos/vxgmichel/asyncio/stargazers","contributors_url":"https://api.github.com/repos/vxgmichel/asyncio/contributors","subscribers_url":"https://api.github.com/repos/vxgmichel/asyncio/subscribers","subscription_url":"https://api.github.com/repos/vxgmichel/asyncio/subscription","commits_url":"https://api.github.com/repos/vxgmichel/asyncio/commits{/sha}","git_commits_url":"https://api.github.com/repos/vxgmichel/asyncio/git/commits{/sha}","comments_url":"https://api.github.com/repos/vxgmichel/asyncio/comments{/number}","issue_comment_url":"https://api.github.com/repos/vxgmichel/asyncio/issues/comments{/number}","contents_url":"https://api.github.com/repos/vxgmichel/asyncio/contents/{+path}","compare_url":"https://api.github.com/repos/vxgmichel/asyncio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vxgmichel/asyncio/merges","archive_url":"https://api.github.com/repos/vxgmichel/asyncio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vxgmichel/asyncio/downloads","issues_url":"https://api.github.com/repos/vxgmichel/asyncio/issues{/number}","pulls_url":"https://api.github.com/repos/vxgmichel/asyncio/pulls{/number}","milestones_url":"https://api.github.com/repos/vxgmichel/asyncio/milestones{/number}","notifications_url":"https://api.github.com/repos/vxgmichel/asyncio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vxgmichel/asyncio/labels{/name}","releases_url":"https://api.github.com/repos/vxgmichel/asyncio/releases{/id}","created_at":"2015-09-28T07:45:26Z","updated_at":"2015-09-28T07:45:29Z","pushed_at":"2015-09-29T23:26:10Z","git_url":"git://github.com/vxgmichel/asyncio.git","ssh_url":"git@github.com:vxgmichel/asyncio.git","clone_url":"https://github.com/vxgmichel/asyncio.git","svn_url":"https://github.com/vxgmichel/asyncio","homepage":"https://github.com/python/asyncio/wiki","size":2382,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":false,"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":"python:master","ref":"master","sha":"47b3f64bef41c5fb6b943dc116a7fda6dcc638b7","user":{"login":"python","id":1525981,"avatar_url":"https://avatars.githubusercontent.com/u/1525981?v=3","gravatar_id":"","url":"https://api.github.com/users/python","html_url":"https://github.com/python","followers_url":"https://api.github.com/users/python/followers","following_url":"https://api.github.com/users/python/following{/other_user}","gists_url":"https://api.github.com/users/python/gists{/gist_id}","starred_url":"https://api.github.com/users/python/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python/subscriptions","organizations_url":"https://api.github.com/users/python/orgs","repos_url":"https://api.github.com/users/python/repos","events_url":"https://api.github.com/users/python/events{/privacy}","received_events_url":"https://api.github.com/users/python/received_events","type":"Organization","site_admin":false},"repo":{"id":33739295,"name":"asyncio","full_name":"python/asyncio","owner":{"login":"python","id":1525981,"avatar_url":"https://avatars.githubusercontent.com/u/1525981?v=3","gravatar_id":"","url":"https://api.github.com/users/python","html_url":"https://github.com/python","followers_url":"https://api.github.com/users/python/followers","following_url":"https://api.github.com/users/python/following{/other_user}","gists_url":"https://api.github.com/users/python/gists{/gist_id}","starred_url":"https://api.github.com/users/python/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/python/subscriptions","organizations_url":"https://api.github.com/users/python/orgs","repos_url":"https://api.github.com/users/python/repos","events_url":"https://api.github.com/users/python/events{/privacy}","received_events_url":"https://api.github.com/users/python/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/python/asyncio","description":"This project is the asyncio module for Python 3.3. Since Python 3.4, asyncio is part of the standard library.","fork":false,"url":"https://api.github.com/repos/python/asyncio","forks_url":"https://api.github.com/repos/python/asyncio/forks","keys_url":"https://api.github.com/repos/python/asyncio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/python/asyncio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/python/asyncio/teams","hooks_url":"https://api.github.com/repos/python/asyncio/hooks","issue_events_url":"https://api.github.com/repos/python/asyncio/issues/events{/number}","events_url":"https://api.github.com/repos/python/asyncio/events","assignees_url":"https://api.github.com/repos/python/asyncio/assignees{/user}","branches_url":"https://api.github.com/repos/python/asyncio/branches{/branch}","tags_url":"https://api.github.com/repos/python/asyncio/tags","blobs_url":"https://api.github.com/repos/python/asyncio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/python/asyncio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/python/asyncio/git/refs{/sha}","trees_url":"https://api.github.com/repos/python/asyncio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/python/asyncio/statuses/{sha}","languages_url":"https://api.github.com/repos/python/asyncio/languages","stargazers_url":"https://api.github.com/repos/python/asyncio/stargazers","contributors_url":"https://api.github.com/repos/python/asyncio/contributors","subscribers_url":"https://api.github.com/repos/python/asyncio/subscribers","subscription_url":"https://api.github.com/repos/python/asyncio/subscription","commits_url":"https://api.github.com/repos/python/asyncio/commits{/sha}","git_commits_url":"https://api.github.com/repos/python/asyncio/git/commits{/sha}","comments_url":"https://api.github.com/repos/python/asyncio/comments{/number}","issue_comment_url":"https://api.github.com/repos/python/asyncio/issues/comments{/number}","contents_url":"https://api.github.com/repos/python/asyncio/contents/{+path}","compare_url":"https://api.github.com/repos/python/asyncio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/python/asyncio/merges","archive_url":"https://api.github.com/repos/python/asyncio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/python/asyncio/downloads","issues_url":"https://api.github.com/repos/python/asyncio/issues{/number}","pulls_url":"https://api.github.com/repos/python/asyncio/pulls{/number}","milestones_url":"https://api.github.com/repos/python/asyncio/milestones{/number}","notifications_url":"https://api.github.com/repos/python/asyncio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/python/asyncio/labels{/name}","releases_url":"https://api.github.com/repos/python/asyncio/releases{/id}","created_at":"2015-04-10T16:41:54Z","updated_at":"2015-09-28T04:29:48Z","pushed_at":"2015-09-29T23:26:10Z","git_url":"git://github.com/python/asyncio.git","ssh_url":"git@github.com:python/asyncio.git","clone_url":"https://github.com/python/asyncio.git","svn_url":"https://github.com/python/asyncio","homepage":"https://github.com/python/asyncio/wiki","size":2382,"stargazers_count":133,"watchers_count":133,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":28,"mirror_url":null,"open_issues_count":37,"forks":28,"open_issues":37,"watchers":133,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/python/asyncio/pulls/273"},"html":{"href":"https://github.com/python/asyncio/pull/273"},"issue":{"href":"https://api.github.com/repos/python/asyncio/issues/273"},"comments":{"href":"https://api.github.com/repos/python/asyncio/issues/273/comments"},"review_comments":{"href":"https://api.github.com/repos/python/asyncio/pulls/273/comments"},"review_comment":{"href":"https://api.github.com/repos/python/asyncio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/python/asyncio/pulls/273/commits"},"statuses":{"href":"https://api.github.com/repos/python/asyncio/statuses/59a0c3c6c5f47ab21212268fe8a127a0d4b320ce"}}}}