manics
March 11, 2022, 8:25pm
2
We recently switched some of the try repos to use JupyterLite to reduce the load on mybinder: Https://jupyter.org/try so slow... Why? - #15 by krassowski
JupyterLite has the big advantage that it runs entirely in the browser so won’t run into problems if there are too many users. There are some differences from normal Python though, and using input
is a known issue- currently using await
is the workaround:
opened 03:01PM - 19 Jul 21 UTC
enhancement
Just wanted to share this issue in case someone has ideas.
### Problem
Wit… h pyolite we can now get a user input with:
```python
i = await input()
```
which is different than what we are used to in ipython:
```python
i = input()
```
The fact that we need to `await` is problematic because it means that wherever this is used, the whole call stack must now be async (you cannot use it in a regular Python function).
### Proposed Solution
There is already a running event loop in Jupyterlite, so we can't just run `input` until complete.
There are two tricks that I know of to work around that, unfortunately they don't work:
- running `input` until complete in another thread with its own event loop (pyolite doesn't support threads).
- using `nest-asyncio` and run `input` until complete in the current event loop (nest-asyncio `Can't patch loop of type <class 'pyodide.webloop.WebLoop'>`).
If you want to use the original Python kernel you can try one of Binder Examples · GitHub
1 Like