{"action":"created","comment":{"url":"https://api.github.com/repos/douban/pymesos/pulls/comments/199047094","pull_request_review_id":133091210,"id":199047094,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTA0NzA5NA==","diff_hunk":"@@ -268,83 +294,87 @@ def _run(self):\n \n             conn = None\n             self.stream_id = None\n-            next_connect_deadline = 0\n-            CONNECT_TIMEOUT = 2\n-            CONNECT_RETRY_INTERVAL = 2\n-            while True:\n-                to_write = set()\n-                to_read = set([_wakeup_fd])\n-                with self._lock:\n-                    if not self._started:\n-                        break\n+            num_conn_retry = 0\n+            connect_deadline = 0\n \n-                    if self._new_master != self._master:\n-                        if conn is not None:\n-                            conn.close()\n-                            conn = None\n-                            self.stream_id = None\n-                            next_connect_deadline = (\n-                                time.time() + CONNECT_RETRY_INTERVAL\n-                            )\n+            while True:\n+                if not conn and self._master:\n+                    conn = Connection(self._master, self)\n \n-                        self._master = self._new_master\n+                    # reset deadline at first retry of every period\n+                    if num_conn_retry < 1:\n+                        connect_deadline = self._timeout + time.time()\n \n-                    if (conn is None and self._master is not None and\n-                            time.time() > next_connect_deadline):\n-                        conn = Connection(self._master, self)\n-                        next_connect_deadline = time.time()\n+                    if time.time() > connect_deadline:\n+                        raise Exception(\"connect reach deadline\")\n \n-                if conn is not None:\n+                to_write = set()\n+                to_read = set([_wakeup_fd])\n+                if conn:\n+                    to_read.add(conn.fileno())\n                     if conn.want_write():\n                         to_write.add(conn.fileno())\n \n-                    to_read.add(conn.fileno())\n+                readable, writeable, _ = select.select(to_read, to_write, [],\n+                                                       SELECT_TIMEOUT)\n+\n+                if _wakeup_fd in readable:\n+                    with self._lock:\n+                        if not self._started:\n+                            break\n+\n+                        if self._new_master != self._master:\n+                            if conn is not None:\n+                                to_read.discard(conn.fileno())\n+                                to_write.discard(conn.fileno())\n+                                conn.close()\n+                                conn = None\n+                                self.stream_id = None\n+                            self._master = self._new_master\n+                            num_conn_retry = 0\n+\n+                    readable.remove(_wakeup_fd)\n+                    os.read(_wakeup_fd, PIPE_BUF)\n+\n+                if not conn or not self._master:\n+                    continue\n+\n+                if not conn.connected:\n+                    err = conn.handle_connect_event()\n+                    if err:\n+                        num_conn_retry += 1","path":"pymesos/process.py","position":168,"original_position":168,"commit_id":"92d7fbfbc2e5fffeb26c5e57b317a7c260f832a3","original_commit_id":"92d7fbfbc2e5fffeb26c5e57b317a7c260f832a3","user":{"login":"youngsofun","id":5782159,"node_id":"MDQ6VXNlcjU3ODIxNTk=","avatar_url":"https://avatars3.githubusercontent.com/u/5782159?v=4","gravatar_id":"","url":"https://api.github.com/users/youngsofun","html_url":"https://github.com/youngsofun","followers_url":"https://api.github.com/users/youngsofun/followers","following_url":"https://api.github.com/users/youngsofun/following{/other_user}","gists_url":"https://api.github.com/users/youngsofun/gists{/gist_id}","starred_url":"https://api.github.com/users/youngsofun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/youngsofun/subscriptions","organizations_url":"https://api.github.com/users/youngsofun/orgs","repos_url":"https://api.github.com/users/youngsofun/repos","events_url":"https://api.github.com/users/youngsofun/events{/privacy}","received_events_url":"https://api.github.com/users/youngsofun/received_events","type":"User","site_admin":false},"body":"两句顺序反了","created_at":"2018-06-29T03:51:51Z","updated_at":"2018-06-29T03:51:51Z","html_url":"https://github.com/douban/pymesos/pull/98#discussion_r199047094","pull_request_url":"https://api.github.com/repos/douban/pymesos/pulls/98","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/douban/pymesos/pulls/comments/199047094"},"html":{"href":"https://github.com/douban/pymesos/pull/98#discussion_r199047094"},"pull_request":{"href":"https://api.github.com/repos/douban/pymesos/pulls/98"}}},"pull_request":{"url":"https://api.github.com/repos/douban/pymesos/pulls/98","id":193870993,"node_id":"MDExOlB1bGxSZXF1ZXN0MTkzODcwOTkz","html_url":"https://github.com/douban/pymesos/pull/98","diff_url":"https://github.com/douban/pymesos/pull/98.diff","patch_url":"https://github.com/douban/pymesos/pull/98.patch","issue_url":"https://api.github.com/repos/douban/pymesos/issues/98","number":98,"state":"open","locked":false,"title":"Add max retry and exponentiation backoff when reconnect to master","user":{"login":"ariesdevil","id":7812909,"node_id":"MDQ6VXNlcjc4MTI5MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/7812909?v=4","gravatar_id":"","url":"https://api.github.com/users/ariesdevil","html_url":"https://github.com/ariesdevil","followers_url":"https://api.github.com/users/ariesdevil/followers","following_url":"https://api.github.com/users/ariesdevil/following{/other_user}","gists_url":"https://api.github.com/users/ariesdevil/gists{/gist_id}","starred_url":"https://api.github.com/users/ariesdevil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariesdevil/subscriptions","organizations_url":"https://api.github.com/users/ariesdevil/orgs","repos_url":"https://api.github.com/users/ariesdevil/repos","events_url":"https://api.github.com/users/ariesdevil/events{/privacy}","received_events_url":"https://api.github.com/users/ariesdevil/received_events","type":"User","site_admin":false},"body":"ref: https://github.com/douban/pymesos/issues/39 and https://github.com/douban/pymesos/issues/97\r\n","created_at":"2018-06-11T04:18:38Z","updated_at":"2018-06-29T03:51:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"60fdac8ec038f1b7bb96262bfca43d1f9d4a4558","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/douban/pymesos/pulls/98/commits","review_comments_url":"https://api.github.com/repos/douban/pymesos/pulls/98/comments","review_comment_url":"https://api.github.com/repos/douban/pymesos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/douban/pymesos/issues/98/comments","statuses_url":"https://api.github.com/repos/douban/pymesos/statuses/92d7fbfbc2e5fffeb26c5e57b317a7c260f832a3","head":{"label":"ariesdevil:dev","ref":"dev","sha":"92d7fbfbc2e5fffeb26c5e57b317a7c260f832a3","user":{"login":"ariesdevil","id":7812909,"node_id":"MDQ6VXNlcjc4MTI5MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/7812909?v=4","gravatar_id":"","url":"https://api.github.com/users/ariesdevil","html_url":"https://github.com/ariesdevil","followers_url":"https://api.github.com/users/ariesdevil/followers","following_url":"https://api.github.com/users/ariesdevil/following{/other_user}","gists_url":"https://api.github.com/users/ariesdevil/gists{/gist_id}","starred_url":"https://api.github.com/users/ariesdevil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariesdevil/subscriptions","organizations_url":"https://api.github.com/users/ariesdevil/orgs","repos_url":"https://api.github.com/users/ariesdevil/repos","events_url":"https://api.github.com/users/ariesdevil/events{/privacy}","received_events_url":"https://api.github.com/users/ariesdevil/received_events","type":"User","site_admin":false},"repo":{"id":136305153,"node_id":"MDEwOlJlcG9zaXRvcnkxMzYzMDUxNTM=","name":"pymesos","full_name":"ariesdevil/pymesos","owner":{"login":"ariesdevil","id":7812909,"node_id":"MDQ6VXNlcjc4MTI5MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/7812909?v=4","gravatar_id":"","url":"https://api.github.com/users/ariesdevil","html_url":"https://github.com/ariesdevil","followers_url":"https://api.github.com/users/ariesdevil/followers","following_url":"https://api.github.com/users/ariesdevil/following{/other_user}","gists_url":"https://api.github.com/users/ariesdevil/gists{/gist_id}","starred_url":"https://api.github.com/users/ariesdevil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariesdevil/subscriptions","organizations_url":"https://api.github.com/users/ariesdevil/orgs","repos_url":"https://api.github.com/users/ariesdevil/repos","events_url":"https://api.github.com/users/ariesdevil/events{/privacy}","received_events_url":"https://api.github.com/users/ariesdevil/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ariesdevil/pymesos","description":"A pure python implementation of Mesos scheduler and executor","fork":true,"url":"https://api.github.com/repos/ariesdevil/pymesos","forks_url":"https://api.github.com/repos/ariesdevil/pymesos/forks","keys_url":"https://api.github.com/repos/ariesdevil/pymesos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ariesdevil/pymesos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ariesdevil/pymesos/teams","hooks_url":"https://api.github.com/repos/ariesdevil/pymesos/hooks","issue_events_url":"https://api.github.com/repos/ariesdevil/pymesos/issues/events{/number}","events_url":"https://api.github.com/repos/ariesdevil/pymesos/events","assignees_url":"https://api.github.com/repos/ariesdevil/pymesos/assignees{/user}","branches_url":"https://api.github.com/repos/ariesdevil/pymesos/branches{/branch}","tags_url":"https://api.github.com/repos/ariesdevil/pymesos/tags","blobs_url":"https://api.github.com/repos/ariesdevil/pymesos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ariesdevil/pymesos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ariesdevil/pymesos/git/refs{/sha}","trees_url":"https://api.github.com/repos/ariesdevil/pymesos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ariesdevil/pymesos/statuses/{sha}","languages_url":"https://api.github.com/repos/ariesdevil/pymesos/languages","stargazers_url":"https://api.github.com/repos/ariesdevil/pymesos/stargazers","contributors_url":"https://api.github.com/repos/ariesdevil/pymesos/contributors","subscribers_url":"https://api.github.com/repos/ariesdevil/pymesos/subscribers","subscription_url":"https://api.github.com/repos/ariesdevil/pymesos/subscription","commits_url":"https://api.github.com/repos/ariesdevil/pymesos/commits{/sha}","git_commits_url":"https://api.github.com/repos/ariesdevil/pymesos/git/commits{/sha}","comments_url":"https://api.github.com/repos/ariesdevil/pymesos/comments{/number}","issue_comment_url":"https://api.github.com/repos/ariesdevil/pymesos/issues/comments{/number}","contents_url":"https://api.github.com/repos/ariesdevil/pymesos/contents/{+path}","compare_url":"https://api.github.com/repos/ariesdevil/pymesos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ariesdevil/pymesos/merges","archive_url":"https://api.github.com/repos/ariesdevil/pymesos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ariesdevil/pymesos/downloads","issues_url":"https://api.github.com/repos/ariesdevil/pymesos/issues{/number}","pulls_url":"https://api.github.com/repos/ariesdevil/pymesos/pulls{/number}","milestones_url":"https://api.github.com/repos/ariesdevil/pymesos/milestones{/number}","notifications_url":"https://api.github.com/repos/ariesdevil/pymesos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ariesdevil/pymesos/labels{/name}","releases_url":"https://api.github.com/repos/ariesdevil/pymesos/releases{/id}","deployments_url":"https://api.github.com/repos/ariesdevil/pymesos/deployments","created_at":"2018-06-06T09:25:00Z","updated_at":"2018-06-06T09:25:02Z","pushed_at":"2018-06-29T02:54:09Z","git_url":"git://github.com/ariesdevil/pymesos.git","ssh_url":"git@github.com:ariesdevil/pymesos.git","clone_url":"https://github.com/ariesdevil/pymesos.git","svn_url":"https://github.com/ariesdevil/pymesos","homepage":"","size":298,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"douban:master","ref":"master","sha":"081cbedb73549d0edf62be94e845f9f08ed3205a","user":{"login":"douban","id":1220164,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyMjAxNjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1220164?v=4","gravatar_id":"","url":"https://api.github.com/users/douban","html_url":"https://github.com/douban","followers_url":"https://api.github.com/users/douban/followers","following_url":"https://api.github.com/users/douban/following{/other_user}","gists_url":"https://api.github.com/users/douban/gists{/gist_id}","starred_url":"https://api.github.com/users/douban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/douban/subscriptions","organizations_url":"https://api.github.com/users/douban/orgs","repos_url":"https://api.github.com/users/douban/repos","events_url":"https://api.github.com/users/douban/events{/privacy}","received_events_url":"https://api.github.com/users/douban/received_events","type":"Organization","site_admin":false},"repo":{"id":24974006,"node_id":"MDEwOlJlcG9zaXRvcnkyNDk3NDAwNg==","name":"pymesos","full_name":"douban/pymesos","owner":{"login":"douban","id":1220164,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyMjAxNjQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1220164?v=4","gravatar_id":"","url":"https://api.github.com/users/douban","html_url":"https://github.com/douban","followers_url":"https://api.github.com/users/douban/followers","following_url":"https://api.github.com/users/douban/following{/other_user}","gists_url":"https://api.github.com/users/douban/gists{/gist_id}","starred_url":"https://api.github.com/users/douban/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/douban/subscriptions","organizations_url":"https://api.github.com/users/douban/orgs","repos_url":"https://api.github.com/users/douban/repos","events_url":"https://api.github.com/users/douban/events{/privacy}","received_events_url":"https://api.github.com/users/douban/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/douban/pymesos","description":"A pure python implementation of Mesos scheduler and executor","fork":false,"url":"https://api.github.com/repos/douban/pymesos","forks_url":"https://api.github.com/repos/douban/pymesos/forks","keys_url":"https://api.github.com/repos/douban/pymesos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/douban/pymesos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/douban/pymesos/teams","hooks_url":"https://api.github.com/repos/douban/pymesos/hooks","issue_events_url":"https://api.github.com/repos/douban/pymesos/issues/events{/number}","events_url":"https://api.github.com/repos/douban/pymesos/events","assignees_url":"https://api.github.com/repos/douban/pymesos/assignees{/user}","branches_url":"https://api.github.com/repos/douban/pymesos/branches{/branch}","tags_url":"https://api.github.com/repos/douban/pymesos/tags","blobs_url":"https://api.github.com/repos/douban/pymesos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/douban/pymesos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/douban/pymesos/git/refs{/sha}","trees_url":"https://api.github.com/repos/douban/pymesos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/douban/pymesos/statuses/{sha}","languages_url":"https://api.github.com/repos/douban/pymesos/languages","stargazers_url":"https://api.github.com/repos/douban/pymesos/stargazers","contributors_url":"https://api.github.com/repos/douban/pymesos/contributors","subscribers_url":"https://api.github.com/repos/douban/pymesos/subscribers","subscription_url":"https://api.github.com/repos/douban/pymesos/subscription","commits_url":"https://api.github.com/repos/douban/pymesos/commits{/sha}","git_commits_url":"https://api.github.com/repos/douban/pymesos/git/commits{/sha}","comments_url":"https://api.github.com/repos/douban/pymesos/comments{/number}","issue_comment_url":"https://api.github.com/repos/douban/pymesos/issues/comments{/number}","contents_url":"https://api.github.com/repos/douban/pymesos/contents/{+path}","compare_url":"https://api.github.com/repos/douban/pymesos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/douban/pymesos/merges","archive_url":"https://api.github.com/repos/douban/pymesos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/douban/pymesos/downloads","issues_url":"https://api.github.com/repos/douban/pymesos/issues{/number}","pulls_url":"https://api.github.com/repos/douban/pymesos/pulls{/number}","milestones_url":"https://api.github.com/repos/douban/pymesos/milestones{/number}","notifications_url":"https://api.github.com/repos/douban/pymesos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/douban/pymesos/labels{/name}","releases_url":"https://api.github.com/repos/douban/pymesos/releases{/id}","deployments_url":"https://api.github.com/repos/douban/pymesos/deployments","created_at":"2014-10-09T04:45:10Z","updated_at":"2018-06-21T03:22:41Z","pushed_at":"2018-06-29T02:54:12Z","git_url":"git://github.com/douban/pymesos.git","ssh_url":"git@github.com:douban/pymesos.git","clone_url":"https://github.com/douban/pymesos.git","svn_url":"https://github.com/douban/pymesos","homepage":"","size":292,"stargazers_count":131,"watchers_count":131,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":74,"mirror_url":null,"archived":false,"open_issues_count":3,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":74,"open_issues":3,"watchers":131,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/douban/pymesos/pulls/98"},"html":{"href":"https://github.com/douban/pymesos/pull/98"},"issue":{"href":"https://api.github.com/repos/douban/pymesos/issues/98"},"comments":{"href":"https://api.github.com/repos/douban/pymesos/issues/98/comments"},"review_comments":{"href":"https://api.github.com/repos/douban/pymesos/pulls/98/comments"},"review_comment":{"href":"https://api.github.com/repos/douban/pymesos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/douban/pymesos/pulls/98/commits"},"statuses":{"href":"https://api.github.com/repos/douban/pymesos/statuses/92d7fbfbc2e5fffeb26c5e57b317a7c260f832a3"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"youngsofun"}}