jupyter / jupyter/notebook

STDIN prompts rendering is nondeterministic with respect to stream outputs

Open
#3,159 6 comments 1 reaction 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
13.3k
Forks
5.8k
Avg merge
6d 11h
Merged PRs (30d)
7

Description

I believe the Jupyter FE is receiving STDIN and stream messages in a nondeterministic order.

Here's a small repro:

```python
import getpass, sys
print (2)
sys.stdout.flush()
_ = getpass.getpass()
```

I would expect this to render 2 before the getpass prompt in all executions. Yet, if I execute this a few times, I occasionally see the reverse order. (Perhaps 1-2 instances in 10 executions.)

Example screenshot:
![screenshot2](https://user-images.githubusercontent.com/151865/34274789-15792b68-e64f-11e7-8a17-1957542db15f.png)

My conjecture is that what is happening is that STDIN channel messages and IOPUB messages are not deterministically ordered for a given cell execution.

Contributor guide

Open the contributing guide

Research direction

Start by running the provided Python repro repeatedly and observing the Jupyter frontend's rendering of STDIN and IOPUB stream messages. Investigate how those messages are ordered for one cell execution; done means the printed 2 consistently appears before the getpass prompt.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, python
Domain
backend, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.