Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: stop jdaviz/voila when the browser window closes #2791

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Bug Fixes

- Fix dropdown selection for table format in export plugin. [#2793]

- Standalone mode: stop jdaviz/voila processes when closing app. [#2791]

Cubeviz
^^^^^^^

Expand Down
21 changes: 20 additions & 1 deletion jdaviz/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,26 @@
VoilaConfiguration.theme = theme
if browser != 'default':
Voila.browser = browser
sys.exit(Voila().launch_instance(argv=[]))

voila = Voila.instance()

Check warning on line 113 in jdaviz/cli.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/cli.py#L113

Added line #L113 was not covered by tests
# monkey patch listen, so we can get a handle on the kernel_manager
# after it is created
previous_listen = voila.listen

Check warning on line 116 in jdaviz/cli.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/cli.py#L116

Added line #L116 was not covered by tests

def listen(*args, **kwargs):

Check warning on line 118 in jdaviz/cli.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/cli.py#L118

Added line #L118 was not covered by tests
# monkey patch remove_kernel, so we can stop the event loop
# when a kernel is removed (which means the browser page was closed)
previous_remove_kernel = voila.kernel_manager.remove_kernel

Check warning on line 121 in jdaviz/cli.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/cli.py#L121

Added line #L121 was not covered by tests

def remove_kernel(kernel_id):
previous_remove_kernel(kernel_id)
voila.ioloop.stop()

Check warning on line 125 in jdaviz/cli.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/cli.py#L123-L125

Added lines #L123 - L125 were not covered by tests

voila.kernel_manager.remove_kernel = remove_kernel
return previous_listen(*args, **kwargs)

Check warning on line 128 in jdaviz/cli.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/cli.py#L127-L128

Added lines #L127 - L128 were not covered by tests

voila.listen = listen
sys.exit(voila.launch_instance(argv=[]))

Check warning on line 131 in jdaviz/cli.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/cli.py#L130-L131

Added lines #L130 - L131 were not covered by tests
finally:
os.chdir(start_dir)

Expand Down