Skip to content

Feature: Run pyodide in worker #808

@joemarshall

Description

@joemarshall

Checklist

  • I added a descriptive title
  • I searched for other feature requests and couldn't find a duplicate (including also the type-feature tag)
  • I confirmed that it's not related to another project area (see the above section)

What is the idea?

It would be nice if you could make pyscript code run in a worker.

Initially without DOM integration, but could add DOM integration via a proxy potentially...

Why is this needed

Personally I like this, because I could move all my testing scripts over to pyscript for things that are supposed to finally run in jupyterlite.

It would be nice generally though if pyscripts didn't hang the browser when doing long running tasks.

What should happen?

I envisage an attribute, so you could do e.g.

<py-script worker="true">
for c in range(1000):
    do_something_slow()
</py-script>

without hanging the browser.

Alternatively, it could be a global option to make all pyodide on a page run in a single worker.

A super cool addition to this feature would be to make a proxy for the main thread js object, so it could still access DOM etc., although I think that probably requires either a) cross site isolation or b) stack switching proposal support to come into browsers, so that normal postmessage / comlink can be used for async calls.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogissue has been triaged but has not been earmarked for any upcoming releasetype: featureNew feature or request

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions