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

WebWorker support #3

Open
ejgallego opened this issue Sep 13, 2024 · 0 comments
Open

WebWorker support #3

ejgallego opened this issue Sep 13, 2024 · 0 comments

Comments

@ejgallego
Copy link

Hi folks,

I've done some experiments as to understand whether we could run pytanque in Jupyter lite, and I think the answer is yes.

I'm opening this issue to document and coordinate such a possible endeavor.

There are two main TODOs to do, on the petanque side, and on the pytanque side:

petanque

For petanque, we need to:

  • create a petanque shell that can be compiled with js_of_ocaml. This is done already by Emilio, it is a very simple wrapper over the current shell, but using Worker's postMessage method instead of writing to stdout. I will submit a PR, and hopefully have coq-lsp CI to generate the .js file
  • have the JS version of petanque to use the coq-pkgs format from JSCoq to load the .vo files; this will require more work, but Emilio plans to do it

pytanque

For pytanque the main TODO is to make the constructor aware of pyodide , so instead of using TCP, it can talk to a web worker.

This seems easy enough, using latest pyodide release I was able to talk to the worker using pyodide.code.run_js and the following code:

var petWorker = new Worker(petWorkerURL);

then petWorker.onmessage and petWorker.postMessage work fine (tested by Emilio).

Maybe the only question remaining is what is the most convenient way to have petWorker.onmessage push the answer to the Python side, but not a big deal IMHO.

some more comments

  • how much to automate the build?
  • wasm version works much better, but needs work for 8.20 as to adapt a stub, tho 8.19 could work, also we could try wasm_of_ocaml.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant