payload: {"action":"created","comment":{"url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls/comments/359535818","pull_request_review_id":334220437,"id":359535818,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDM1OTUzNTgxOA==","diff_hunk":"@@ -71,3 +75,16 @@ def _remove_session(self, name):\n         else:\n             raise SessionManagementException(u\"Could not find '{}' session in list of saved sessions. Possible sessions are {}\"\n                                              .format(name, self.get_sessions_list()))\n+\n+    def _register_cleanup_on_exit(self):\n+        \"\"\"\n+        Stop the livy sessions before python process exits for any reason (if enabled in conf)\n+        \"\"\"\n+        if conf.cleanup_all_sessions_on_exit():\n+            def cleanup_spark_sessions():\n+                try:\n+                    self.clean_up_all()\n+                except Exception:\n+                    pass","path":"sparkmagic/sparkmagic/livyclientlib/sessionmanager.py","position":37,"original_position":37,"commit_id":"63da90ae4287f65856a1406c6d1203c3f34cb1da","original_commit_id":"63da90ae4287f65856a1406c6d1203c3f34cb1da","user":{"login":"itamarst","id":3266662,"node_id":"MDQ6VXNlcjMyNjY2NjI=","avatar_url":"https://avatars1.githubusercontent.com/u/3266662?v=4","gravatar_id":"","url":"https://api.github.com/users/itamarst","html_url":"https://github.com/itamarst","followers_url":"https://api.github.com/users/itamarst/followers","following_url":"https://api.github.com/users/itamarst/following{/other_user}","gists_url":"https://api.github.com/users/itamarst/gists{/gist_id}","starred_url":"https://api.github.com/users/itamarst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itamarst/subscriptions","organizations_url":"https://api.github.com/users/itamarst/orgs","repos_url":"https://api.github.com/users/itamarst/repos","events_url":"https://api.github.com/users/itamarst/events{/privacy}","received_events_url":"https://api.github.com/users/itamarst/received_events","type":"User","site_admin":false},"body":"Should probably log the error here.","created_at":"2019-12-18T19:47:06Z","updated_at":"2019-12-18T19:47:41Z","html_url":"https://github.com/jupyter-incubator/sparkmagic/pull/595#discussion_r359535818","pull_request_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls/595","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls/comments/359535818"},"html":{"href":"https://github.com/jupyter-incubator/sparkmagic/pull/595#discussion_r359535818"},"pull_request":{"href":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls/595"}}},"pull_request":{"url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls/595","id":346842011,"node_id":"MDExOlB1bGxSZXF1ZXN0MzQ2ODQyMDEx","html_url":"https://github.com/jupyter-incubator/sparkmagic/pull/595","diff_url":"https://github.com/jupyter-incubator/sparkmagic/pull/595.diff","patch_url":"https://github.com/jupyter-incubator/sparkmagic/pull/595.patch","issue_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/issues/595","number":595,"state":"open","locked":false,"title":"New conf option 'cleanup_all_sessions_on_exit'","user":{"login":"juhoautio","id":4446608,"node_id":"MDQ6VXNlcjQ0NDY2MDg=","avatar_url":"https://avatars3.githubusercontent.com/u/4446608?v=4","gravatar_id":"","url":"https://api.github.com/users/juhoautio","html_url":"https://github.com/juhoautio","followers_url":"https://api.github.com/users/juhoautio/followers","following_url":"https://api.github.com/users/juhoautio/following{/other_user}","gists_url":"https://api.github.com/users/juhoautio/gists{/gist_id}","starred_url":"https://api.github.com/users/juhoautio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juhoautio/subscriptions","organizations_url":"https://api.github.com/users/juhoautio/orgs","repos_url":"https://api.github.com/users/juhoautio/repos","events_url":"https://api.github.com/users/juhoautio/events{/privacy}","received_events_url":"https://api.github.com/users/juhoautio/received_events","type":"User","site_admin":false},"body":"New conf option `cleanup_all_sessions_on_exit` (boolean)\r\n- Default: `False`\r\n\r\nThe existing `shutdown_session_on_spark_statement_errors` conf allows ensuring that livy sessions are shut down only in case of a Spark error.\r\n\r\nThis new option helps ensuring that livy sessions are not left behind also when there's a non-Spark error, or if the notebook exits gracefully but user forgot to do cleanup.\r\n\r\n----\r\n\r\nAlso added docs to README on how to set conf overrides programmatically.\r\n\r\n----\r\n\r\nTested this manually with a minimal Notebook\r\n\r\n<img width=\"1029\" alt=\"Näyttökuva 2019-11-29 kello 0 12 38\" src=\"https://user-images.githubusercontent.com/4446608/69833526-06866f00-123d-11ea-8697-21b2e781c107.png\">\r\n\r\nI also tested starting a session with `%spark add -s smoke -l python -u http://my-host:8998` and shutting down the notebook caused Livy session to be stopped, as desired.","created_at":"2019-11-28T22:05:54Z","updated_at":"2019-12-18T19:47:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6d8dbd1845b9b2040a8df4278a0c93ae85edd8be","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls/595/commits","review_comments_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls/595/comments","review_comment_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/issues/595/comments","statuses_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/statuses/63da90ae4287f65856a1406c6d1203c3f34cb1da","head":{"label":"juhoautio:terminate_on_exit","ref":"terminate_on_exit","sha":"63da90ae4287f65856a1406c6d1203c3f34cb1da","user":{"login":"juhoautio","id":4446608,"node_id":"MDQ6VXNlcjQ0NDY2MDg=","avatar_url":"https://avatars3.githubusercontent.com/u/4446608?v=4","gravatar_id":"","url":"https://api.github.com/users/juhoautio","html_url":"https://github.com/juhoautio","followers_url":"https://api.github.com/users/juhoautio/followers","following_url":"https://api.github.com/users/juhoautio/following{/other_user}","gists_url":"https://api.github.com/users/juhoautio/gists{/gist_id}","starred_url":"https://api.github.com/users/juhoautio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juhoautio/subscriptions","organizations_url":"https://api.github.com/users/juhoautio/orgs","repos_url":"https://api.github.com/users/juhoautio/repos","events_url":"https://api.github.com/users/juhoautio/events{/privacy}","received_events_url":"https://api.github.com/users/juhoautio/received_events","type":"User","site_admin":false},"repo":{"id":224736087,"node_id":"MDEwOlJlcG9zaXRvcnkyMjQ3MzYwODc=","name":"sparkmagic","full_name":"juhoautio/sparkmagic","private":false,"owner":{"login":"juhoautio","id":4446608,"node_id":"MDQ6VXNlcjQ0NDY2MDg=","avatar_url":"https://avatars3.githubusercontent.com/u/4446608?v=4","gravatar_id":"","url":"https://api.github.com/users/juhoautio","html_url":"https://github.com/juhoautio","followers_url":"https://api.github.com/users/juhoautio/followers","following_url":"https://api.github.com/users/juhoautio/following{/other_user}","gists_url":"https://api.github.com/users/juhoautio/gists{/gist_id}","starred_url":"https://api.github.com/users/juhoautio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juhoautio/subscriptions","organizations_url":"https://api.github.com/users/juhoautio/orgs","repos_url":"https://api.github.com/users/juhoautio/repos","events_url":"https://api.github.com/users/juhoautio/events{/privacy}","received_events_url":"https://api.github.com/users/juhoautio/received_events","type":"User","site_admin":false},"html_url":"https://github.com/juhoautio/sparkmagic","description":"Jupyter magics and kernels for working with remote Spark clusters","fork":true,"url":"https://api.github.com/repos/juhoautio/sparkmagic","forks_url":"https://api.github.com/repos/juhoautio/sparkmagic/forks","keys_url":"https://api.github.com/repos/juhoautio/sparkmagic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/juhoautio/sparkmagic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/juhoautio/sparkmagic/teams","hooks_url":"https://api.github.com/repos/juhoautio/sparkmagic/hooks","issue_events_url":"https://api.github.com/repos/juhoautio/sparkmagic/issues/events{/number}","events_url":"https://api.github.com/repos/juhoautio/sparkmagic/events","assignees_url":"https://api.github.com/repos/juhoautio/sparkmagic/assignees{/user}","branches_url":"https://api.github.com/repos/juhoautio/sparkmagic/branches{/branch}","tags_url":"https://api.github.com/repos/juhoautio/sparkmagic/tags","blobs_url":"https://api.github.com/repos/juhoautio/sparkmagic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/juhoautio/sparkmagic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/juhoautio/sparkmagic/git/refs{/sha}","trees_url":"https://api.github.com/repos/juhoautio/sparkmagic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/juhoautio/sparkmagic/statuses/{sha}","languages_url":"https://api.github.com/repos/juhoautio/sparkmagic/languages","stargazers_url":"https://api.github.com/repos/juhoautio/sparkmagic/stargazers","contributors_url":"https://api.github.com/repos/juhoautio/sparkmagic/contributors","subscribers_url":"https://api.github.com/repos/juhoautio/sparkmagic/subscribers","subscription_url":"https://api.github.com/repos/juhoautio/sparkmagic/subscription","commits_url":"https://api.github.com/repos/juhoautio/sparkmagic/commits{/sha}","git_commits_url":"https://api.github.com/repos/juhoautio/sparkmagic/git/commits{/sha}","comments_url":"https://api.github.com/repos/juhoautio/sparkmagic/comments{/number}","issue_comment_url":"https://api.github.com/repos/juhoautio/sparkmagic/issues/comments{/number}","contents_url":"https://api.github.com/repos/juhoautio/sparkmagic/contents/{+path}","compare_url":"https://api.github.com/repos/juhoautio/sparkmagic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/juhoautio/sparkmagic/merges","archive_url":"https://api.github.com/repos/juhoautio/sparkmagic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/juhoautio/sparkmagic/downloads","issues_url":"https://api.github.com/repos/juhoautio/sparkmagic/issues{/number}","pulls_url":"https://api.github.com/repos/juhoautio/sparkmagic/pulls{/number}","milestones_url":"https://api.github.com/repos/juhoautio/sparkmagic/milestones{/number}","notifications_url":"https://api.github.com/repos/juhoautio/sparkmagic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/juhoautio/sparkmagic/labels{/name}","releases_url":"https://api.github.com/repos/juhoautio/sparkmagic/releases{/id}","deployments_url":"https://api.github.com/repos/juhoautio/sparkmagic/deployments","created_at":"2019-11-28T21:59:56Z","updated_at":"2019-11-28T21:59:58Z","pushed_at":"2019-11-28T22:31:22Z","git_url":"git://github.com/juhoautio/sparkmagic.git","ssh_url":"git@github.com:juhoautio/sparkmagic.git","clone_url":"https://github.com/juhoautio/sparkmagic.git","svn_url":"https://github.com/juhoautio/sparkmagic","homepage":"","size":1828,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"jupyter-incubator:master","ref":"master","sha":"38d23e74f1ab86f75a310c136bc28eef00ac60d9","user":{"login":"jupyter-incubator","id":14002361,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MDAyMzYx","avatar_url":"https://avatars0.githubusercontent.com/u/14002361?v=4","gravatar_id":"","url":"https://api.github.com/users/jupyter-incubator","html_url":"https://github.com/jupyter-incubator","followers_url":"https://api.github.com/users/jupyter-incubator/followers","following_url":"https://api.github.com/users/jupyter-incubator/following{/other_user}","gists_url":"https://api.github.com/users/jupyter-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/jupyter-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jupyter-incubator/subscriptions","organizations_url":"https://api.github.com/users/jupyter-incubator/orgs","repos_url":"https://api.github.com/users/jupyter-incubator/repos","events_url":"https://api.github.com/users/jupyter-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/jupyter-incubator/received_events","type":"Organization","site_admin":false},"repo":{"id":42875585,"node_id":"MDEwOlJlcG9zaXRvcnk0Mjg3NTU4NQ==","name":"sparkmagic","full_name":"jupyter-incubator/sparkmagic","private":false,"owner":{"login":"jupyter-incubator","id":14002361,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE0MDAyMzYx","avatar_url":"https://avatars0.githubusercontent.com/u/14002361?v=4","gravatar_id":"","url":"https://api.github.com/users/jupyter-incubator","html_url":"https://github.com/jupyter-incubator","followers_url":"https://api.github.com/users/jupyter-incubator/followers","following_url":"https://api.github.com/users/jupyter-incubator/following{/other_user}","gists_url":"https://api.github.com/users/jupyter-incubator/gists{/gist_id}","starred_url":"https://api.github.com/users/jupyter-incubator/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jupyter-incubator/subscriptions","organizations_url":"https://api.github.com/users/jupyter-incubator/orgs","repos_url":"https://api.github.com/users/jupyter-incubator/repos","events_url":"https://api.github.com/users/jupyter-incubator/events{/privacy}","received_events_url":"https://api.github.com/users/jupyter-incubator/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/jupyter-incubator/sparkmagic","description":"Jupyter magics and kernels for working with remote Spark clusters","fork":false,"url":"https://api.github.com/repos/jupyter-incubator/sparkmagic","forks_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/forks","keys_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/teams","hooks_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/hooks","issue_events_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/issues/events{/number}","events_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/events","assignees_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/assignees{/user}","branches_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/branches{/branch}","tags_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/tags","blobs_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/git/refs{/sha}","trees_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/statuses/{sha}","languages_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/languages","stargazers_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/stargazers","contributors_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/contributors","subscribers_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/subscribers","subscription_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/subscription","commits_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/commits{/sha}","git_commits_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/git/commits{/sha}","comments_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/comments{/number}","issue_comment_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/issues/comments{/number}","contents_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/contents/{+path}","compare_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/merges","archive_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/downloads","issues_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/issues{/number}","pulls_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls{/number}","milestones_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/milestones{/number}","notifications_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/labels{/name}","releases_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/releases{/id}","deployments_url":"https://api.github.com/repos/jupyter-incubator/sparkmagic/deployments","created_at":"2015-09-21T15:35:25Z","updated_at":"2019-12-18T02:30:16Z","pushed_at":"2019-12-11T21:06:23Z","git_url":"git://github.com/jupyter-incubator/sparkmagic.git","ssh_url":"git@github.com:jupyter-incubator/sparkmagic.git","clone_url":"https://github.com/jupyter-incubator/sparkmagic.git","svn_url":"https://github.com/jupyter-incubator/sparkmagic","homepage":"","size":1819,"stargazers_count":744,"watchers_count":744,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":272,"mirror_url":null,"archived":false,"disabled":false,"open_issues_count":96,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":272,"open_issues":96,"watchers":744,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls/595"},"html":{"href":"https://github.com/jupyter-incubator/sparkmagic/pull/595"},"issue":{"href":"https://api.github.com/repos/jupyter-incubator/sparkmagic/issues/595"},"comments":{"href":"https://api.github.com/repos/jupyter-incubator/sparkmagic/issues/595/comments"},"review_comments":{"href":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls/595/comments"},"review_comment":{"href":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jupyter-incubator/sparkmagic/pulls/595/commits"},"statuses":{"href":"https://api.github.com/repos/jupyter-incubator/sparkmagic/statuses/63da90ae4287f65856a1406c6d1203c3f34cb1da"}},"author_association":"NONE"}}
other: {"actor":{"display_login":"itamarst"}}