{"action":"created","comment":{"url":"https://api.github.com/repos/2gis/vmmaster/pulls/comments/144764184","pull_request_review_id":69464811,"id":144764184,"diff_hunk":"@@ -54,6 +56,49 @@ def stop(self):\n         log.info(\"Preloader stopped\")\n \n \n+class EndpointRemover(Thread):\n+    def __init__(self, pool):\n+        Thread.__init__(self)\n+        self.running = True\n+        self.daemon = True\n+        self.pool = pool\n+\n+    def remove_endpoint(self, endpoint):\n+        try:\n+            with self.pool.app.app_context():\n+                session = self.pool.app.database.get_session_by_endpoint_id(endpoint.id)\n+                if session:\n+                    self.pool.save_artifacts(session)\n+                    self.pool.artifact_collector.wait_for_complete(session.id)\n+                endpoint.delete(try_to_rebuild=True)\n+        except:\n+            log.exception(\"Failed\")\n+            endpoint.send_to_service()\n+\n+    def on_success(self, r):\n+        log.info(\"Success\")\n+\n+    @staticmethod\n+    def on_failure(r):\n+        log.exception(\"Service was failed: {}\".format(r))\n+\n+    def run(self):\n+        log.info(\"EndpointRemover was started...\")\n+        while self.running:\n+            with self.pool.app.app_context():\n+                with ThreadPoolExecutor(max_workers=constants.ENDPOINT_REMOVER_THREADS) as executor:\n+                    for endpoint in self.pool.wait_for_service:\n+                        endpoint.service_mode_on()\n+                        executor.submit(self.remove_endpoint, endpoint)\n+            time.sleep(constants.TIME_OF_SLEEP_AFTER_ATTEMPT)","path":"vmpool/virtual_machines_pool.py","position":48,"original_position":48,"commit_id":"d55d42c7dd558403715b3c7c42ce6266dd9bce03","original_commit_id":"6476e4abd8156c9bb81d1fae84d8c54f6026a012","user":{"login":"z00sts","id":5012880,"avatar_url":"https://avatars1.githubusercontent.com/u/5012880?v=4","gravatar_id":"","url":"https://api.github.com/users/z00sts","html_url":"https://github.com/z00sts","followers_url":"https://api.github.com/users/z00sts/followers","following_url":"https://api.github.com/users/z00sts/following{/other_user}","gists_url":"https://api.github.com/users/z00sts/gists{/gist_id}","starred_url":"https://api.github.com/users/z00sts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/z00sts/subscriptions","organizations_url":"https://api.github.com/users/z00sts/orgs","repos_url":"https://api.github.com/users/z00sts/repos","events_url":"https://api.github.com/users/z00sts/events{/privacy}","received_events_url":"https://api.github.com/users/z00sts/received_events","type":"User","site_admin":false},"body":"Давай замутим, чтобы Удалятор юзал экзекутор вот так:\r\n`with self.executor() as executor:`\r\n\r\nСпрячем в инит вот это `ThreadPoolExecutor(max_workers=constants.ENDPOINT_REMOVER_THREADS)`","created_at":"2017-10-16T06:37:58Z","updated_at":"2017-10-16T06:37:58Z","html_url":"https://github.com/2gis/vmmaster/pull/262#discussion_r144764184","pull_request_url":"https://api.github.com/repos/2gis/vmmaster/pulls/262","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/2gis/vmmaster/pulls/comments/144764184"},"html":{"href":"https://github.com/2gis/vmmaster/pull/262#discussion_r144764184"},"pull_request":{"href":"https://api.github.com/repos/2gis/vmmaster/pulls/262"}},"in_reply_to_id":144501653},"pull_request":{"url":"https://api.github.com/repos/2gis/vmmaster/pulls/262","id":146202807,"html_url":"https://github.com/2gis/vmmaster/pull/262","diff_url":"https://github.com/2gis/vmmaster/pull/262.diff","patch_url":"https://github.com/2gis/vmmaster/pull/262.patch","issue_url":"https://api.github.com/repos/2gis/vmmaster/issues/262","number":262,"state":"open","locked":false,"title":"EndpointRemover","user":{"login":"sh0ked","id":3863442,"avatar_url":"https://avatars2.githubusercontent.com/u/3863442?v=4","gravatar_id":"","url":"https://api.github.com/users/sh0ked","html_url":"https://github.com/sh0ked","followers_url":"https://api.github.com/users/sh0ked/followers","following_url":"https://api.github.com/users/sh0ked/following{/other_user}","gists_url":"https://api.github.com/users/sh0ked/gists{/gist_id}","starred_url":"https://api.github.com/users/sh0ked/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sh0ked/subscriptions","organizations_url":"https://api.github.com/users/sh0ked/orgs","repos_url":"https://api.github.com/users/sh0ked/repos","events_url":"https://api.github.com/users/sh0ked/events{/privacy}","received_events_url":"https://api.github.com/users/sh0ked/received_events","type":"User","site_admin":false},"body":"- remove save_artifacts from Session\r\n- delete endpoint through VirtualMachinePool and by EndpointRemover\r\n- service mode for Endpoint","created_at":"2017-10-12T13:02:19Z","updated_at":"2017-10-16T06:37:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"157274ae7dbe6aef5c978f54b03af7702350ff32","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/2gis/vmmaster/pulls/262/commits","review_comments_url":"https://api.github.com/repos/2gis/vmmaster/pulls/262/comments","review_comment_url":"https://api.github.com/repos/2gis/vmmaster/pulls/comments{/number}","comments_url":"https://api.github.com/repos/2gis/vmmaster/issues/262/comments","statuses_url":"https://api.github.com/repos/2gis/vmmaster/statuses/d55d42c7dd558403715b3c7c42ce6266dd9bce03","head":{"label":"2gis:endpoint-remover","ref":"endpoint-remover","sha":"d55d42c7dd558403715b3c7c42ce6266dd9bce03","user":{"login":"2gis","id":1481435,"avatar_url":"https://avatars2.githubusercontent.com/u/1481435?v=4","gravatar_id":"","url":"https://api.github.com/users/2gis","html_url":"https://github.com/2gis","followers_url":"https://api.github.com/users/2gis/followers","following_url":"https://api.github.com/users/2gis/following{/other_user}","gists_url":"https://api.github.com/users/2gis/gists{/gist_id}","starred_url":"https://api.github.com/users/2gis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2gis/subscriptions","organizations_url":"https://api.github.com/users/2gis/orgs","repos_url":"https://api.github.com/users/2gis/repos","events_url":"https://api.github.com/users/2gis/events{/privacy}","received_events_url":"https://api.github.com/users/2gis/received_events","type":"Organization","site_admin":false},"repo":{"id":31351213,"name":"vmmaster","full_name":"2gis/vmmaster","owner":{"login":"2gis","id":1481435,"avatar_url":"https://avatars2.githubusercontent.com/u/1481435?v=4","gravatar_id":"","url":"https://api.github.com/users/2gis","html_url":"https://github.com/2gis","followers_url":"https://api.github.com/users/2gis/followers","following_url":"https://api.github.com/users/2gis/following{/other_user}","gists_url":"https://api.github.com/users/2gis/gists{/gist_id}","starred_url":"https://api.github.com/users/2gis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2gis/subscriptions","organizations_url":"https://api.github.com/users/2gis/orgs","repos_url":"https://api.github.com/users/2gis/repos","events_url":"https://api.github.com/users/2gis/events{/privacy}","received_events_url":"https://api.github.com/users/2gis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/2gis/vmmaster","description":"Automatic virtual machines manager for selenium-based testing","fork":false,"url":"https://api.github.com/repos/2gis/vmmaster","forks_url":"https://api.github.com/repos/2gis/vmmaster/forks","keys_url":"https://api.github.com/repos/2gis/vmmaster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/2gis/vmmaster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/2gis/vmmaster/teams","hooks_url":"https://api.github.com/repos/2gis/vmmaster/hooks","issue_events_url":"https://api.github.com/repos/2gis/vmmaster/issues/events{/number}","events_url":"https://api.github.com/repos/2gis/vmmaster/events","assignees_url":"https://api.github.com/repos/2gis/vmmaster/assignees{/user}","branches_url":"https://api.github.com/repos/2gis/vmmaster/branches{/branch}","tags_url":"https://api.github.com/repos/2gis/vmmaster/tags","blobs_url":"https://api.github.com/repos/2gis/vmmaster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/2gis/vmmaster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/2gis/vmmaster/git/refs{/sha}","trees_url":"https://api.github.com/repos/2gis/vmmaster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/2gis/vmmaster/statuses/{sha}","languages_url":"https://api.github.com/repos/2gis/vmmaster/languages","stargazers_url":"https://api.github.com/repos/2gis/vmmaster/stargazers","contributors_url":"https://api.github.com/repos/2gis/vmmaster/contributors","subscribers_url":"https://api.github.com/repos/2gis/vmmaster/subscribers","subscription_url":"https://api.github.com/repos/2gis/vmmaster/subscription","commits_url":"https://api.github.com/repos/2gis/vmmaster/commits{/sha}","git_commits_url":"https://api.github.com/repos/2gis/vmmaster/git/commits{/sha}","comments_url":"https://api.github.com/repos/2gis/vmmaster/comments{/number}","issue_comment_url":"https://api.github.com/repos/2gis/vmmaster/issues/comments{/number}","contents_url":"https://api.github.com/repos/2gis/vmmaster/contents/{+path}","compare_url":"https://api.github.com/repos/2gis/vmmaster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/2gis/vmmaster/merges","archive_url":"https://api.github.com/repos/2gis/vmmaster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/2gis/vmmaster/downloads","issues_url":"https://api.github.com/repos/2gis/vmmaster/issues{/number}","pulls_url":"https://api.github.com/repos/2gis/vmmaster/pulls{/number}","milestones_url":"https://api.github.com/repos/2gis/vmmaster/milestones{/number}","notifications_url":"https://api.github.com/repos/2gis/vmmaster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/2gis/vmmaster/labels{/name}","releases_url":"https://api.github.com/repos/2gis/vmmaster/releases{/id}","deployments_url":"https://api.github.com/repos/2gis/vmmaster/deployments","created_at":"2015-02-26T04:53:56Z","updated_at":"2017-03-21T05:42:12Z","pushed_at":"2017-10-16T06:36:09Z","git_url":"git://github.com/2gis/vmmaster.git","ssh_url":"git@github.com:2gis/vmmaster.git","clone_url":"https://github.com/2gis/vmmaster.git","svn_url":"https://github.com/2gis/vmmaster","homepage":"","size":1156,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":6,"forks":4,"open_issues":6,"watchers":8,"default_branch":"master"}},"base":{"label":"2gis:master","ref":"master","sha":"1cbe1f63d0dc287b05a92ee42cc1f834add82edb","user":{"login":"2gis","id":1481435,"avatar_url":"https://avatars2.githubusercontent.com/u/1481435?v=4","gravatar_id":"","url":"https://api.github.com/users/2gis","html_url":"https://github.com/2gis","followers_url":"https://api.github.com/users/2gis/followers","following_url":"https://api.github.com/users/2gis/following{/other_user}","gists_url":"https://api.github.com/users/2gis/gists{/gist_id}","starred_url":"https://api.github.com/users/2gis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2gis/subscriptions","organizations_url":"https://api.github.com/users/2gis/orgs","repos_url":"https://api.github.com/users/2gis/repos","events_url":"https://api.github.com/users/2gis/events{/privacy}","received_events_url":"https://api.github.com/users/2gis/received_events","type":"Organization","site_admin":false},"repo":{"id":31351213,"name":"vmmaster","full_name":"2gis/vmmaster","owner":{"login":"2gis","id":1481435,"avatar_url":"https://avatars2.githubusercontent.com/u/1481435?v=4","gravatar_id":"","url":"https://api.github.com/users/2gis","html_url":"https://github.com/2gis","followers_url":"https://api.github.com/users/2gis/followers","following_url":"https://api.github.com/users/2gis/following{/other_user}","gists_url":"https://api.github.com/users/2gis/gists{/gist_id}","starred_url":"https://api.github.com/users/2gis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/2gis/subscriptions","organizations_url":"https://api.github.com/users/2gis/orgs","repos_url":"https://api.github.com/users/2gis/repos","events_url":"https://api.github.com/users/2gis/events{/privacy}","received_events_url":"https://api.github.com/users/2gis/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/2gis/vmmaster","description":"Automatic virtual machines manager for selenium-based testing","fork":false,"url":"https://api.github.com/repos/2gis/vmmaster","forks_url":"https://api.github.com/repos/2gis/vmmaster/forks","keys_url":"https://api.github.com/repos/2gis/vmmaster/keys{/key_id}","collaborators_url":"https://api.github.com/repos/2gis/vmmaster/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/2gis/vmmaster/teams","hooks_url":"https://api.github.com/repos/2gis/vmmaster/hooks","issue_events_url":"https://api.github.com/repos/2gis/vmmaster/issues/events{/number}","events_url":"https://api.github.com/repos/2gis/vmmaster/events","assignees_url":"https://api.github.com/repos/2gis/vmmaster/assignees{/user}","branches_url":"https://api.github.com/repos/2gis/vmmaster/branches{/branch}","tags_url":"https://api.github.com/repos/2gis/vmmaster/tags","blobs_url":"https://api.github.com/repos/2gis/vmmaster/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/2gis/vmmaster/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/2gis/vmmaster/git/refs{/sha}","trees_url":"https://api.github.com/repos/2gis/vmmaster/git/trees{/sha}","statuses_url":"https://api.github.com/repos/2gis/vmmaster/statuses/{sha}","languages_url":"https://api.github.com/repos/2gis/vmmaster/languages","stargazers_url":"https://api.github.com/repos/2gis/vmmaster/stargazers","contributors_url":"https://api.github.com/repos/2gis/vmmaster/contributors","subscribers_url":"https://api.github.com/repos/2gis/vmmaster/subscribers","subscription_url":"https://api.github.com/repos/2gis/vmmaster/subscription","commits_url":"https://api.github.com/repos/2gis/vmmaster/commits{/sha}","git_commits_url":"https://api.github.com/repos/2gis/vmmaster/git/commits{/sha}","comments_url":"https://api.github.com/repos/2gis/vmmaster/comments{/number}","issue_comment_url":"https://api.github.com/repos/2gis/vmmaster/issues/comments{/number}","contents_url":"https://api.github.com/repos/2gis/vmmaster/contents/{+path}","compare_url":"https://api.github.com/repos/2gis/vmmaster/compare/{base}...{head}","merges_url":"https://api.github.com/repos/2gis/vmmaster/merges","archive_url":"https://api.github.com/repos/2gis/vmmaster/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/2gis/vmmaster/downloads","issues_url":"https://api.github.com/repos/2gis/vmmaster/issues{/number}","pulls_url":"https://api.github.com/repos/2gis/vmmaster/pulls{/number}","milestones_url":"https://api.github.com/repos/2gis/vmmaster/milestones{/number}","notifications_url":"https://api.github.com/repos/2gis/vmmaster/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/2gis/vmmaster/labels{/name}","releases_url":"https://api.github.com/repos/2gis/vmmaster/releases{/id}","deployments_url":"https://api.github.com/repos/2gis/vmmaster/deployments","created_at":"2015-02-26T04:53:56Z","updated_at":"2017-03-21T05:42:12Z","pushed_at":"2017-10-16T06:36:09Z","git_url":"git://github.com/2gis/vmmaster.git","ssh_url":"git@github.com:2gis/vmmaster.git","clone_url":"https://github.com/2gis/vmmaster.git","svn_url":"https://github.com/2gis/vmmaster","homepage":"","size":1156,"stargazers_count":8,"watchers_count":8,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":6,"forks":4,"open_issues":6,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/2gis/vmmaster/pulls/262"},"html":{"href":"https://github.com/2gis/vmmaster/pull/262"},"issue":{"href":"https://api.github.com/repos/2gis/vmmaster/issues/262"},"comments":{"href":"https://api.github.com/repos/2gis/vmmaster/issues/262/comments"},"review_comments":{"href":"https://api.github.com/repos/2gis/vmmaster/pulls/262/comments"},"review_comment":{"href":"https://api.github.com/repos/2gis/vmmaster/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/2gis/vmmaster/pulls/262/commits"},"statuses":{"href":"https://api.github.com/repos/2gis/vmmaster/statuses/d55d42c7dd558403715b3c7c42ce6266dd9bce03"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"z00sts"}}