{"action":"created","issue":{"url":"https://api.github.com/repos/joeyespo/grip/issues/136","labels_url":"https://api.github.com/repos/joeyespo/grip/issues/136/labels{/name}","comments_url":"https://api.github.com/repos/joeyespo/grip/issues/136/comments","events_url":"https://api.github.com/repos/joeyespo/grip/issues/136/events","html_url":"https://github.com/joeyespo/grip/pull/136","id":93031050,"number":136,"title":"Stop browser opening consuming all the sockets","user":{"login":"markbt","id":5471678,"avatar_url":"https://avatars.githubusercontent.com/u/5471678?v=3","gravatar_id":"","url":"https://api.github.com/users/markbt","html_url":"https://github.com/markbt","followers_url":"https://api.github.com/users/markbt/followers","following_url":"https://api.github.com/users/markbt/following{/other_user}","gists_url":"https://api.github.com/users/markbt/gists{/gist_id}","starred_url":"https://api.github.com/users/markbt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markbt/subscriptions","organizations_url":"https://api.github.com/users/markbt/orgs","repos_url":"https://api.github.com/users/markbt/repos","events_url":"https://api.github.com/users/markbt/events{/privacy}","received_events_url":"https://api.github.com/users/markbt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-04T17:10:23Z","updated_at":"2015-07-05T04:00:56Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/joeyespo/grip/pulls/136","html_url":"https://github.com/joeyespo/grip/pull/136","diff_url":"https://github.com/joeyespo/grip/pull/136.diff","patch_url":"https://github.com/joeyespo/grip/pull/136.patch"},"body":"The sense of the test in `is_server_running` is inverted.\r\n\r\nThis means `wait_for_server` races with the server starting:\r\n- If the server starts first, `wait_for_server` will never return, and will quickly consume all available ephemeral ports on the system.\r\n- If the server doesn't start first, `wait_for_server` returns immediately and the browser opens to a blank page.\r\n\r\nThis fix:\r\n- Fixes the sense of the test, and makes the code more explicit\r\n- Adds a delay in `wait_for_server` so that ephemeral sockets aren't rapidly consumed while we wait for it to start."},"comment":{"url":"https://api.github.com/repos/joeyespo/grip/issues/comments/118577094","html_url":"https://github.com/joeyespo/grip/pull/136#issuecomment-118577094","issue_url":"https://api.github.com/repos/joeyespo/grip/issues/136","id":118577094,"user":{"login":"joeyespo","id":634573,"avatar_url":"https://avatars.githubusercontent.com/u/634573?v=3","gravatar_id":"","url":"https://api.github.com/users/joeyespo","html_url":"https://github.com/joeyespo","followers_url":"https://api.github.com/users/joeyespo/followers","following_url":"https://api.github.com/users/joeyespo/following{/other_user}","gists_url":"https://api.github.com/users/joeyespo/gists{/gist_id}","starred_url":"https://api.github.com/users/joeyespo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeyespo/subscriptions","organizations_url":"https://api.github.com/users/joeyespo/orgs","repos_url":"https://api.github.com/users/joeyespo/repos","events_url":"https://api.github.com/users/joeyespo/events{/privacy}","received_events_url":"https://api.github.com/users/joeyespo/received_events","type":"User","site_admin":false},"created_at":"2015-07-05T04:00:56Z","updated_at":"2015-07-05T04:00:56Z","body":"Beat me to it. Glad to see you came to the same conclusion with the logic inversion and adding a `sleep` delay.\r\n\r\nI was also wondering if adding `sock.close()` was necessary here if `rc == 0`. I was still seeing some strange behavior, however I usually run Grip with Werkzeug's `debug=True`, so that might be causing some other side effects with this. Have any thoughts about `sock.close()`?\r\n\r\nThanks for the fix, @markbt!\r\n"}}