{"action":"created","comment":{"url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls/comments/207249489","pull_request_review_id":142821773,"id":207249489,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNzI0OTQ4OQ==","diff_hunk":"@@ -765,44 +846,81 @@ def get_module_doc(self, module):\n         return data\n \n     def is_ansible_alive(self):\n-        if self.ansible_process is None:\n+        if self.runner_thread is None:\n+            logger.info(\"NOT STARTED\")\n             return False\n-        return self.ansible_process.poll() is None\n+        if self.runner_thread.is_alive():\n+            logger.info(\"YES\")\n+        else:\n+            logger.info(\"NO\")\n+        return self.runner_thread.is_alive()\n \n-    def do_shutdown(self, restart):\n+    def cancel_callback(self):\n+        logger.info('called')\n+        return self.shutdown_requested\n \n-        logger = logging.getLogger('ansible_kernel.kernel.do_shutdown')\n+    def finished_callback(self, runner):\n+        logger.info('called')\n+        self.shutdown = True\n+        if not self.shutdown_requested:\n+            self.queue.put(StatusMessage(['PlaybookEnded', {}]))\n \n-        if self.ansible_process is None:\n-            logger.debug(\"No ansible process\")\n-            return\n+    def do_shutdown(self, restart):\n \n-        try:\n-            current_process = psutil.Process(self.ansible_process.pid)\n-            children = current_process.children(recursive=True)\n-            for child in children:\n-                print('Child pid is {}'.format(child.pid))\n-        except psutil.NoSuchProcess:\n-            pass\n \n         if self.is_ansible_alive():\n-            logger.info('killing ansible {0}'.format(self.ansible_process.pid))\n-            try:\n-                self.ansible_process.kill()\n-            except psutil.NoSuchProcess:\n-                logger.info('process already dead {0}'.format(self.ansible_process.pid))\n-            for child in children:\n-                logger.info('killing ansible sub {0}'.format(child.pid))\n-                try:\n-                    child.kill()\n-                except psutil.NoSuchProcess:\n-                    logger.info('process already dead {0}'.format(child.pid))\n-\n-        logger.info('stopping helper')\n-        self.helper.stop()\n-        self.helper = None\n-        self.tasks_counter = 0\n+            self.shutdown = False\n+            self.shutdown_requested = True\n+\n+            while not self.shutdown:\n+                if not self.is_ansible_alive():\n+                    break\n+                logger.info(\"waiting for shutdown\")\n+                time.sleep(1)\n+            logger.info(\"shutdown complete\")\n+\n+        self.shutdown_requested = False\n+        self.runner_thread = None\n+        self.runner = None\n+        if self.helper is not None:\n+            self.helper.stop()","path":"ansible_kernel/kernel.py","position":523,"original_position":523,"commit_id":"16e8d1db33e02e75c105d959c65699a7eb2182b4","original_commit_id":"16e8d1db33e02e75c105d959c65699a7eb2182b4","user":{"login":"matburt","id":89544,"node_id":"MDQ6VXNlcjg5NTQ0","avatar_url":"https://avatars0.githubusercontent.com/u/89544?v=4","gravatar_id":"","url":"https://api.github.com/users/matburt","html_url":"https://github.com/matburt","followers_url":"https://api.github.com/users/matburt/followers","following_url":"https://api.github.com/users/matburt/following{/other_user}","gists_url":"https://api.github.com/users/matburt/gists{/gist_id}","starred_url":"https://api.github.com/users/matburt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matburt/subscriptions","organizations_url":"https://api.github.com/users/matburt/orgs","repos_url":"https://api.github.com/users/matburt/repos","events_url":"https://api.github.com/users/matburt/events{/privacy}","received_events_url":"https://api.github.com/users/matburt/received_events","type":"User","site_admin":false},"body":"This looks okay for shutting the thread down... do you know if Runner is able to kill the things correctly or does it leave orphans?","created_at":"2018-08-02T14:33:13Z","updated_at":"2018-08-02T14:41:32Z","html_url":"https://github.com/ansible/ansible-jupyter-kernel/pull/54#discussion_r207249489","pull_request_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls/54","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls/comments/207249489"},"html":{"href":"https://github.com/ansible/ansible-jupyter-kernel/pull/54#discussion_r207249489"},"pull_request":{"href":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls/54"}}},"pull_request":{"url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls/54","id":205748690,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1NzQ4Njkw","html_url":"https://github.com/ansible/ansible-jupyter-kernel/pull/54","diff_url":"https://github.com/ansible/ansible-jupyter-kernel/pull/54.diff","patch_url":"https://github.com/ansible/ansible-jupyter-kernel/pull/54.patch","issue_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/issues/54","number":54,"state":"open","locked":false,"title":"Change backend to use ansible-runner","user":{"login":"benthomasson","id":44381,"node_id":"MDQ6VXNlcjQ0Mzgx","avatar_url":"https://avatars0.githubusercontent.com/u/44381?v=4","gravatar_id":"","url":"https://api.github.com/users/benthomasson","html_url":"https://github.com/benthomasson","followers_url":"https://api.github.com/users/benthomasson/followers","following_url":"https://api.github.com/users/benthomasson/following{/other_user}","gists_url":"https://api.github.com/users/benthomasson/gists{/gist_id}","starred_url":"https://api.github.com/users/benthomasson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benthomasson/subscriptions","organizations_url":"https://api.github.com/users/benthomasson/orgs","repos_url":"https://api.github.com/users/benthomasson/repos","events_url":"https://api.github.com/users/benthomasson/events{/privacy}","received_events_url":"https://api.github.com/users/benthomasson/received_events","type":"User","site_admin":false},"body":"## Status\r\n**Ready**\r\n\r\n## Description\r\n\r\nAdds ansible-runner as the ansible execution manager instead of calling ansible-playbook with Popen.\r\n\r\nNow has feature parity with 0.7.0 where we call ansible-playbook directly. \r\n\r\n\r\nAddresses #2 ","created_at":"2018-08-02T14:11:08Z","updated_at":"2018-08-02T14:41:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7b7de456795752a7484e4bff74e22531c4bd12a9","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls/54/commits","review_comments_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls/54/comments","review_comment_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/issues/54/comments","statuses_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/statuses/16e8d1db33e02e75c105d959c65699a7eb2182b4","head":{"label":"benthomasson:ansible_runner_backend_ben","ref":"ansible_runner_backend_ben","sha":"16e8d1db33e02e75c105d959c65699a7eb2182b4","user":{"login":"benthomasson","id":44381,"node_id":"MDQ6VXNlcjQ0Mzgx","avatar_url":"https://avatars0.githubusercontent.com/u/44381?v=4","gravatar_id":"","url":"https://api.github.com/users/benthomasson","html_url":"https://github.com/benthomasson","followers_url":"https://api.github.com/users/benthomasson/followers","following_url":"https://api.github.com/users/benthomasson/following{/other_user}","gists_url":"https://api.github.com/users/benthomasson/gists{/gist_id}","starred_url":"https://api.github.com/users/benthomasson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benthomasson/subscriptions","organizations_url":"https://api.github.com/users/benthomasson/orgs","repos_url":"https://api.github.com/users/benthomasson/repos","events_url":"https://api.github.com/users/benthomasson/events{/privacy}","received_events_url":"https://api.github.com/users/benthomasson/received_events","type":"User","site_admin":false},"repo":{"id":138751634,"node_id":"MDEwOlJlcG9zaXRvcnkxMzg3NTE2MzQ=","name":"ansible-jupyter-kernel","full_name":"benthomasson/ansible-jupyter-kernel","owner":{"login":"benthomasson","id":44381,"node_id":"MDQ6VXNlcjQ0Mzgx","avatar_url":"https://avatars0.githubusercontent.com/u/44381?v=4","gravatar_id":"","url":"https://api.github.com/users/benthomasson","html_url":"https://github.com/benthomasson","followers_url":"https://api.github.com/users/benthomasson/followers","following_url":"https://api.github.com/users/benthomasson/following{/other_user}","gists_url":"https://api.github.com/users/benthomasson/gists{/gist_id}","starred_url":"https://api.github.com/users/benthomasson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benthomasson/subscriptions","organizations_url":"https://api.github.com/users/benthomasson/orgs","repos_url":"https://api.github.com/users/benthomasson/repos","events_url":"https://api.github.com/users/benthomasson/events{/privacy}","received_events_url":"https://api.github.com/users/benthomasson/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/benthomasson/ansible-jupyter-kernel","description":null,"fork":true,"url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel","forks_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/forks","keys_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/teams","hooks_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/hooks","issue_events_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/issues/events{/number}","events_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/events","assignees_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/assignees{/user}","branches_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/branches{/branch}","tags_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/tags","blobs_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/git/refs{/sha}","trees_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/statuses/{sha}","languages_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/languages","stargazers_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/stargazers","contributors_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/contributors","subscribers_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/subscribers","subscription_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/subscription","commits_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/commits{/sha}","git_commits_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/git/commits{/sha}","comments_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/comments{/number}","issue_comment_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/issues/comments{/number}","contents_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/contents/{+path}","compare_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/merges","archive_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/downloads","issues_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/issues{/number}","pulls_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/pulls{/number}","milestones_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/milestones{/number}","notifications_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/labels{/name}","releases_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/releases{/id}","deployments_url":"https://api.github.com/repos/benthomasson/ansible-jupyter-kernel/deployments","created_at":"2018-06-26T14:41:21Z","updated_at":"2018-08-02T14:08:15Z","pushed_at":"2018-08-02T14:18:47Z","git_url":"git://github.com/benthomasson/ansible-jupyter-kernel.git","ssh_url":"git@github.com:benthomasson/ansible-jupyter-kernel.git","clone_url":"https://github.com/benthomasson/ansible-jupyter-kernel.git","svn_url":"https://github.com/benthomasson/ansible-jupyter-kernel","homepage":null,"size":1333,"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":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ansible:master","ref":"master","sha":"818bf2f9577dda22892f090b2db1143261d6640f","user":{"login":"ansible","id":1507452,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MDc0NTI=","avatar_url":"https://avatars2.githubusercontent.com/u/1507452?v=4","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"repo":{"id":138749883,"node_id":"MDEwOlJlcG9zaXRvcnkxMzg3NDk4ODM=","name":"ansible-jupyter-kernel","full_name":"ansible/ansible-jupyter-kernel","owner":{"login":"ansible","id":1507452,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MDc0NTI=","avatar_url":"https://avatars2.githubusercontent.com/u/1507452?v=4","gravatar_id":"","url":"https://api.github.com/users/ansible","html_url":"https://github.com/ansible","followers_url":"https://api.github.com/users/ansible/followers","following_url":"https://api.github.com/users/ansible/following{/other_user}","gists_url":"https://api.github.com/users/ansible/gists{/gist_id}","starred_url":"https://api.github.com/users/ansible/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ansible/subscriptions","organizations_url":"https://api.github.com/users/ansible/orgs","repos_url":"https://api.github.com/users/ansible/repos","events_url":"https://api.github.com/users/ansible/events{/privacy}","received_events_url":"https://api.github.com/users/ansible/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ansible/ansible-jupyter-kernel","description":"Jupyter Notebook Kernel for running Ansible Tasks and Playbooks","fork":false,"url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel","forks_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/forks","keys_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/teams","hooks_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/hooks","issue_events_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/issues/events{/number}","events_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/events","assignees_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/assignees{/user}","branches_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/branches{/branch}","tags_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/tags","blobs_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/git/refs{/sha}","trees_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/statuses/{sha}","languages_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/languages","stargazers_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/stargazers","contributors_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/contributors","subscribers_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/subscribers","subscription_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/subscription","commits_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/commits{/sha}","git_commits_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/git/commits{/sha}","comments_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/comments{/number}","issue_comment_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/issues/comments{/number}","contents_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/contents/{+path}","compare_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/merges","archive_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/downloads","issues_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/issues{/number}","pulls_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls{/number}","milestones_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/milestones{/number}","notifications_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/labels{/name}","releases_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/releases{/id}","deployments_url":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/deployments","created_at":"2018-06-26T14:28:02Z","updated_at":"2018-08-02T14:40:19Z","pushed_at":"2018-08-02T14:18:47Z","git_url":"git://github.com/ansible/ansible-jupyter-kernel.git","ssh_url":"git@github.com:ansible/ansible-jupyter-kernel.git","clone_url":"https://github.com/ansible/ansible-jupyter-kernel.git","svn_url":"https://github.com/ansible/ansible-jupyter-kernel","homepage":"","size":1307,"stargazers_count":312,"watchers_count":312,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"archived":false,"open_issues_count":9,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":16,"open_issues":9,"watchers":312,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls/54"},"html":{"href":"https://github.com/ansible/ansible-jupyter-kernel/pull/54"},"issue":{"href":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/issues/54"},"comments":{"href":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/issues/54/comments"},"review_comments":{"href":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls/54/comments"},"review_comment":{"href":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/pulls/54/commits"},"statuses":{"href":"https://api.github.com/repos/ansible/ansible-jupyter-kernel/statuses/16e8d1db33e02e75c105d959c65699a7eb2182b4"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"matburt"}}