{"action":"created","issue":{"url":"https://api.github.com/repos/benjamin-hodgson/asynqp/issues/14","labels_url":"https://api.github.com/repos/benjamin-hodgson/asynqp/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/benjamin-hodgson/asynqp/issues/14/comments","events_url":"https://api.github.com/repos/benjamin-hodgson/asynqp/issues/14/events","html_url":"https://github.com/benjamin-hodgson/asynqp/pull/14","id":73758811,"number":14,"title":"do not pass host and port to loop.create_connection when there's a sock","user":{"login":"urbaniak","id":25346,"avatar_url":"https://avatars.githubusercontent.com/u/25346?v=3","gravatar_id":"","url":"https://api.github.com/users/urbaniak","html_url":"https://github.com/urbaniak","followers_url":"https://api.github.com/users/urbaniak/followers","following_url":"https://api.github.com/users/urbaniak/following{/other_user}","gists_url":"https://api.github.com/users/urbaniak/gists{/gist_id}","starred_url":"https://api.github.com/users/urbaniak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/urbaniak/subscriptions","organizations_url":"https://api.github.com/users/urbaniak/orgs","repos_url":"https://api.github.com/users/urbaniak/repos","events_url":"https://api.github.com/users/urbaniak/events{/privacy}","received_events_url":"https://api.github.com/users/urbaniak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-05-06T22:37:41Z","updated_at":"2015-05-07T13:08:18Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/benjamin-hodgson/asynqp/pulls/14","html_url":"https://github.com/benjamin-hodgson/asynqp/pull/14","diff_url":"https://github.com/benjamin-hodgson/asynqp/pull/14.diff","patch_url":"https://github.com/benjamin-hodgson/asynqp/pull/14.patch"},"body":"asyncio create_connection allows to pass a sock param with already open file descriptor number to use it instead of opening new connection to host/port.\r\n\r\nIt's raising an Exception: \"host/port and sock can not be specified at the same time\" when trying to pass sock as a keyword argument to asynqp.connect().\r\n\r\nThat's an easy way to allow both approaches work fine and be compliant with asyncio api.\r\n\r\nPassing open socket descriptor is a common practice to restart an application without loosing any data from already open socket - it's used by gunicorn, uwsgi, nginx, etc.\r\n"},"comment":{"url":"https://api.github.com/repos/benjamin-hodgson/asynqp/issues/comments/99858557","html_url":"https://github.com/benjamin-hodgson/asynqp/pull/14#issuecomment-99858557","issue_url":"https://api.github.com/repos/benjamin-hodgson/asynqp/issues/14","id":99858557,"user":{"login":"benjamin-hodgson","id":3857587,"avatar_url":"https://avatars.githubusercontent.com/u/3857587?v=3","gravatar_id":"","url":"https://api.github.com/users/benjamin-hodgson","html_url":"https://github.com/benjamin-hodgson","followers_url":"https://api.github.com/users/benjamin-hodgson/followers","following_url":"https://api.github.com/users/benjamin-hodgson/following{/other_user}","gists_url":"https://api.github.com/users/benjamin-hodgson/gists{/gist_id}","starred_url":"https://api.github.com/users/benjamin-hodgson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benjamin-hodgson/subscriptions","organizations_url":"https://api.github.com/users/benjamin-hodgson/orgs","repos_url":"https://api.github.com/users/benjamin-hodgson/repos","events_url":"https://api.github.com/users/benjamin-hodgson/events{/privacy}","received_events_url":"https://api.github.com/users/benjamin-hodgson/received_events","type":"User","site_admin":false},"created_at":"2015-05-07T13:08:18Z","updated_at":"2015-05-07T13:08:18Z","body":"Something like this ought to do the trick (I just pasted and adjusted an existing, similar test):\r\n\r\n```python\r\nclass WhenConnectingWithAnExistingSocket:\r\n    def given_the_loop_and_a_socket(self):\r\n        self.loop = asyncio.get_event_loop()\r\n        self.sock = socket.socket()  # set up the socket appropriately\r\n\r\n    def when_I_connect(self):\r\n        self.connection = self.loop.run_until_complete(asyncio.wait_for(asynqp.connect(sock=self.sock), 0.2))\r\n\r\n    def it_should_connect(self):\r\n        assert self.connection is not None\r\n\r\n    def cleanup_the_connection(self):\r\n        self.loop.run_until_complete(asyncio.wait_for(self.connection.close(), 0.2))\r\n```\r\n\r\nI am a little confused about what you're trying to achieve in your example. It looks like you are trying to set up a second `Connection` which uses the same `socket` as an existing `Connection`. That doesn't seem like a good idea to me. Why are you trying to do that?"}}