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

Remove asynchronous=False from runJavaScript calls #84

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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: 1 addition & 1 deletion glue_wwt/viewer/tests/test_wwt_widget.py
Original file line number Diff line number Diff line change
@@ -154,7 +154,7 @@ def test_remove_layer(self):
assert subset_layer.wwt_layer is None

# @pytest.mark.skipif(sys.platform == 'win32', reason="Test causes issues on Windows")
@pytest.mark.xfail(reason="'asynchronous' keyword unsupported by some JavaScript versions")
# @pytest.mark.xfail(reason="'asynchronous' keyword unsupported by some JavaScript versions")
def test_save_tour(self, tmpdir):

filename = tmpdir.join('mytour.wtt').strpath
17 changes: 7 additions & 10 deletions glue_wwt/viewer/tools.py
Original file line number Diff line number Diff line change
@@ -83,22 +83,19 @@ def activate(self):
if not filename.endswith('.wtt'):
filename = filename + '.wtt'

self.viewer._wwt.widget.page.runJavaScript("tourxml = '';", asynchronous=False)
tourxml = self.viewer._wwt.widget.page.runJavaScript('tourxml;', asynchronous=False)
self.viewer._wwt.widget.page.runJavaScript("tourxml = '';")
tourxml = self.viewer._wwt.widget.page.runJavaScript('tourxml;')

self.viewer._wwt.widget.page.runJavaScript(SAVE_TOUR_CODE)

start = time.time()
tourxml = None
while time.time() - start < 10:
time.sleep(0.1)
app.processEvents()
tourxml = self.viewer._wwt.widget.page.runJavaScript('tourxml;', asynchronous=False)
if tourxml:
break
time.sleep(1)
app.processEvents()
time.sleep(1)
tourxml = self.viewer._wwt.widget.page.runJavaScript('tourxml;')

if not tourxml:
raise Exception("Failed to save tour")
raise ChildProcessError(f"Failed to save tour: {tourxml}")

# Patch the altUnit so that it is correct for the Windows client (since
# the web client currently has other bugs with relation to loading tours).