diff --git a/peps/pep-0818.rst b/peps/pep-0818.rst index 525d8ec8cfa..22919ea03b2 100644 --- a/peps/pep-0818.rst +++ b/peps/pep-0818.rst @@ -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.) The fact that the Pyodide foreign function interface is coupled to Pyodide creates problems for other Emscripten-CPython distributions. For instance, @@ -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 ========= @@ -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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~