Skip to content
Merged
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
20 changes: 16 additions & 4 deletions peps/pep-0818.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ requires making calls into JavaScript: for example, it is required to display
content to the screen, to receive user input, to handle events, to access
databases, etc. For instance, once Python has a JavaScript foreign function
interface, it will be possible to support ``urllib`` on Emscripten. Downstream,
supporting ``urllib3``, ``aiohttp``, and ``httpx`` requires the foreign function
interface.
supporting ``urllib3``, ``aiohttp``, ``httpx``, ``matplotlib``, ``bokeh``, and
other projects that do I/O requires the foreign function interface. (By itself,
this PEP is only enough to support asynchronous I/O. All of ``urllib``,
``urllib3`` and ``requests`` expose synchronous APIs and require stack switching
to support.)
Comment thread
savannahostrowski marked this conversation as resolved.
Resolved

The fact that the Pyodide foreign function interface is coupled to Pyodide
creates problems for other Emscripten-CPython distributions. For instance,
Expand All @@ -76,9 +79,12 @@ CPython.
.. _Emscripten-forge: https://emscripten-forge.org/

In order to keep the length of this PEP reasonable, we focus on the "core" of
the foreign function interface. The JavaScript interface for managing the Python
runtime is left to a future PEP.
the foreign function interface. The following things are left to future
proposals:

* A JavaScript interface for managing the Python interpreter lifecycle
* Stack switching support, and in particular support for blocking for the
completion of an awaitable (e.g., ``run_until_complete()``)

Rationale
=========
Expand Down Expand Up @@ -1356,6 +1362,12 @@ Promise methods ``then()``, ``catch()`` and ``finally_()``. This is so that code
can work consistently regardless of whether they have a ``Promise``, a
``WebFuture`` or a ``WebTask``.

In order to implement ``run_until_complete()``, we need stack switching support
in the runtime. Downstream, Pyodide has implemented stack switching support and
``run_until_complete()`` works as expected. Until we have such stack switching
support, ``run_until_complete()`` will raise a ``NotImplementedError``. This
will be the topic of a followup proposal.

Adapting from a Python awaitable to a JavaScript awaitable
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
Loading