pyscript / polyscript

Polyscript - PyScript single core to rule them all
Apache License 2.0
48 stars 4 forks source link

Polyscript workers by name #106

Closed WebReflection closed 4 months ago

WebReflection commented 4 months ago

This MR brings in a new polyscript workers export which allows workers to be named and be retrieved without sync indirections. If the worker code has an __export__ = ["method_1", "other_method"] defined in it those methods will be attached to sync out of the box and provided back as worker utility, bypassing all other sync possibilities, yet improving DX around this topic.

<script type="micropython" async>
from polyscript import workers

test = await workers["test"]
version = await test.pyodide_version()
print(version)
</script>
<script type="pyodide" worker name="test">
def pyodide_version():
    import sys
    return sys.version

__export__ = ['pyodide_version']
</script>