Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Wait (blocking) for data when using PtyProcess #95

Merged
merged 2 commits into from
May 23, 2018

Conversation

nanoant
Copy link
Contributor

@nanoant nanoant commented Mar 9, 2018

This is alternative solution to the problem described at jupyter/terminado#54 and pull request workaround #94.

Instead of doing any time.sleep PtyProcess read thread it is simply blocking waiting for stdout data. When the underlyiung console process dies, console pipe gets closed so read exits as well.

Notes

I have tested it with pytest and manually using JupyterLab console.

Commit notes

Previously PtyProcess thread was using non-blocking calls to read which
was effectively caused high-CPU usage, which was partially mitigated
by time.sleep(0.1).

NOTE: When console process dies the pipe gets closed, causing read to
return as well.

Also, removed superfluous pty = pty_fixture() calls from PtyProcess
that made tests hang with blocking approach on cmd.exe.

Previously PtyProcess thread was using non-blocking calls to read which
was effectively caused high-CPU usage, which was partially mitigated
by time.sleep(0.1).

NOTE: When console process dies the pipe gets closed, causing read to
return as well.

Also, removed superfluous `pty = pty_fixture()` calls from PtyProcess
that made tests hang with blocking approach on `cmd.exe`.
@blink1073
Copy link
Collaborator

Thanks! This change LGTM, but will need to wait for some build chain updates for CI to pass. cf #90 (comment)

@ccordoba12 ccordoba12 added this to the v0.5.2 milestone Mar 9, 2018
@nanoant
Copy link
Contributor Author

nanoant commented Mar 11, 2018

@blink1073 @ccordoba12 Great! Thanks for the positive review. Cheers, Adam.

@scimax
Copy link

scimax commented Mar 16, 2018

Thank you for your fix! The cpu usage improved a lot immediately! I copied the changes over manually although some checks were not successful. Before it was not possible to use the terminal over a long time.

@dhirschfeld
Copy link

What's the status of this PR? Is there anything I can do to help get this merged?

@ccordoba12
Copy link
Contributor

We need to fix our testing infrastructure here, due to changes in how winpty is compiled in conda/conda-forge.

We hope to start working on it next week.

@andfoy andfoy merged commit 2145471 into andfoy:master May 23, 2018
@ccordoba12 ccordoba12 changed the title Wait (blocking) for data when using PtyProcess PR: Wait (blocking) for data when using PtyProcess May 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants