{"action":"opened","number":264,"pull_request":{"url":"https://api.github.com/repos/python/asyncio/pulls/264","id":45742637,"html_url":"https://github.com/python/asyncio/pull/264","diff_url":"https://github.com/python/asyncio/pull/264.diff","patch_url":"https://github.com/python/asyncio/pull/264.patch","issue_url":"https://api.github.com/repos/python/asyncio/issues/264","number":264,"state":"open","locked":false,"title":"Add a mechanism in `create_server` to set custom socket options","user":{"login":"jashandeep-sohi","id":1811200,"avatar_url":"https://avatars.githubusercontent.com/u/1811200?v=3","gravatar_id":"","url":"https://api.github.com/users/jashandeep-sohi","html_url":"https://github.com/jashandeep-sohi","followers_url":"https://api.github.com/users/jashandeep-sohi/followers","following_url":"https://api.github.com/users/jashandeep-sohi/following{/other_user}","gists_url":"https://api.github.com/users/jashandeep-sohi/gists{/gist_id}","starred_url":"https://api.github.com/users/jashandeep-sohi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jashandeep-sohi/subscriptions","organizations_url":"https://api.github.com/users/jashandeep-sohi/orgs","repos_url":"https://api.github.com/users/jashandeep-sohi/repos","events_url":"https://api.github.com/users/jashandeep-sohi/events{/privacy}","received_events_url":"https://api.github.com/users/jashandeep-sohi/received_events","type":"User","site_admin":false},"body":"Sometimes you need to set some socket options before the socket is bound (e.g. `SO_REUSEPORT` on Linux 3.9+). I think `asyncio` should provide a mechanism by which this could be done using the `create_server` coroutine.\r\n\r\nI know I could manually create the socket, set any options and then pass it in to `create_server`, but this would involve writing all the `getaddrinfo` logic again. I would also be limited to just one socket.\r\nI also don't think adding another argument like `reuse_port` is the right way to go. It might solve the `SO_REUSEPORT`, but provides no other way to set other options.\r\n\r\nMy solution is to provide a callback function as an argument to `create_server` that will be called with a socket just before it is bound. This callback has the signature `f(sock)` and it's return value is ignored. The best name that I could think of for the argument was `sock_config_cb`, but if that's not clear it should probably be changed.\r\n\r\nIf there is a better way of setting options before the socket is bound, please do tell.","created_at":"2015-09-23T04:20:13Z","updated_at":"2015-09-23T04:20:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"370362d654d07829b6407287eeb94ccc6e876a7c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/python/asyncio/pulls/264/commits","review_comments_url":"https://api.github.com/repos/python/asyncio/pulls/264/comments","review_comment_url":"https://api.github.com/repos/python/asyncio/pulls/comments{/number}","comments_url":"https://api.github.com/repos/python/asyncio/issues/264/comments","statuses_url":"https://api.github.com/repos/python/asyncio/statuses/7affde1e04e0b3a595e73b4ca72846cd6c93c43d","head":{"label":"jashandeep-sohi:sock-cb","ref":"sock-cb","sha":"7affde1e04e0b3a595e73b4ca72846cd6c93c43d","user":{"login":"jashandeep-sohi","id":1811200,"avatar_url":"https://avatars.githubusercontent.com/u/1811200?v=3","gravatar_id":"","url":"https://api.github.com/users/jashandeep-sohi","html_url":"https://github.com/jashandeep-sohi","followers_url":"https://api.github.com/users/jashandeep-sohi/followers","following_url":"https://api.github.com/users/jashandeep-sohi/following{/other_user}","gists_url":"https://api.github.com/users/jashandeep-sohi/gists{/gist_id}","starred_url":"https://api.github.com/users/jashandeep-sohi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jashandeep-sohi/subscriptions","organizations_url":"https://api.github.com/users/jashandeep-sohi/orgs","repos_url":"https://api.github.com/users/jashandeep-sohi/repos","events_url":"https://api.github.com/users/jashandeep-sohi/events{/privacy}","received_events_url":"https://api.github.com/users/jashandeep-sohi/received_events","type":"User","site_admin":false},"repo":{"id":42971242,"name":"asyncio","full_name":"jashandeep-sohi/asyncio","owner":{"login":"jashandeep-sohi","id":1811200,"avatar_url":"https://avatars.githubusercontent.com/u/1811200?v=3","gravatar_id":"","url":"https://api.github.com/users/jashandeep-sohi","html_url":"https://github.com/jashandeep-sohi","followers_url":"https://api.github.com/users/jashandeep-sohi/followers","following_url":"https://api.github.com/users/jashandeep-sohi/following{/other_user}","gists_url":"https://api.github.com/users/jashandeep-sohi/gists{/gist_id}","starred_url":"https://api.github.com/users/jashandeep-sohi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jashandeep-sohi/subscriptions","organizations_url":"https://api.github.com/users/jashandeep-sohi/orgs","repos_url":"https://api.github.com/users/jashandeep-sohi/repos","events_url":"https://api.github.com/users/jashandeep-sohi/events{/privacy}","received_events_url":"https://api.github.com/users/jashandeep-sohi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jashandeep-sohi/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/jashandeep-sohi/asyncio","forks_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/forks","keys_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/teams","hooks_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/hooks","issue_events_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/issues/events{/number}","events_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/events","assignees_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/assignees{/user}","branches_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/branches{/branch}","tags_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/tags","blobs_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/git/refs{/sha}","trees_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/statuses/{sha}","languages_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/languages","stargazers_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/stargazers","contributors_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/contributors","subscribers_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/subscribers","subscription_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/subscription","commits_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/commits{/sha}","git_commits_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/git/commits{/sha}","comments_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/comments{/number}","issue_comment_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/issues/comments{/number}","contents_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/contents/{+path}","compare_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/merges","archive_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/downloads","issues_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/issues{/number}","pulls_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/pulls{/number}","milestones_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/milestones{/number}","notifications_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/labels{/name}","releases_url":"https://api.github.com/repos/jashandeep-sohi/asyncio/releases{/id}","created_at":"2015-09-23T01:35:12Z","updated_at":"2015-09-23T01:35:13Z","pushed_at":"2015-09-23T02:29:32Z","git_url":"git://github.com/jashandeep-sohi/asyncio.git","ssh_url":"git@github.com:jashandeep-sohi/asyncio.git","clone_url":"https://github.com/jashandeep-sohi/asyncio.git","svn_url":"https://github.com/jashandeep-sohi/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-22T14:57:19Z","pushed_at":"2015-09-23T04:20:15Z","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":131,"watchers_count":131,"language":"Python","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":23,"mirror_url":null,"open_issues_count":35,"forks":23,"open_issues":35,"watchers":131,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/python/asyncio/pulls/264"},"html":{"href":"https://github.com/python/asyncio/pull/264"},"issue":{"href":"https://api.github.com/repos/python/asyncio/issues/264"},"comments":{"href":"https://api.github.com/repos/python/asyncio/issues/264/comments"},"review_comments":{"href":"https://api.github.com/repos/python/asyncio/pulls/264/comments"},"review_comment":{"href":"https://api.github.com/repos/python/asyncio/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/python/asyncio/pulls/264/commits"},"statuses":{"href":"https://api.github.com/repos/python/asyncio/statuses/7affde1e04e0b3a595e73b4ca72846cd6c93c43d"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":3,"deletions":1,"changed_files":1}}