Move pyodide to a web worker (#1333)

This PR adds support for optionally running pyodide in a web worker:

- add a new option config.execution_thread, which can be `main` or `worker`. The default is `main`

- improve the test machinery so that we run all tests twice, once for `main` and once for `worker`

- add a new esbuild target which builds the code for the worker

The support for workers is not complete and many features are still missing: there are 71 tests which are marked as `@skip_worker`, but we can fix them in subsequent PRs.

The vast majority of tests fail because js.document is unavailable: for it to run transparently, we need the "auto-syncify" feature of synclink.


Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
Co-authored-by: Madhur Tandon <20173739+madhur-tandon@users.noreply.github.com>
This commit is contained in:
Antonio Cuni
2023-04-14 10:55:31 +02:00
committed by GitHub
parent dfa116eb70
commit 8c5475f78f
28 changed files with 497 additions and 99 deletions

View File

@@ -1,9 +1,10 @@
import re
from .support import PyScriptTest
from .support import PyScriptTest, skip_worker
class TestDocsSnippets(PyScriptTest):
@skip_worker("FIXME: js.document")
def test_tutorials_py_click(self):
self.pyscript_run(
"""
@@ -65,6 +66,7 @@ class TestDocsSnippets(PyScriptTest):
assert "userId" in py_terminal.inner_text()
self.assert_no_banners()
@skip_worker("FIXME: js.document")
def test_tutorials_py_config_fetch(self):
# flake8: noqa
self.pyscript_run(
@@ -147,6 +149,7 @@ class TestDocsSnippets(PyScriptTest):
assert "0.22.0a3" in py_terminal.inner_text()
self.assert_no_banners()
@skip_worker("FIXME: display()")
def test_tutorials_writing_to_page(self):
self.pyscript_run(
"""