Skip to content

Conversation

@Oshuma
Copy link
Contributor

@Oshuma Oshuma commented Apr 13, 2020

Issue #196

The only thing left is to steam stdout/stderr to Jupyter. I couldn't quite figure out how to do that, so if anyone could give me some pointers/examples, I can implement it.

@cosmos72
Copy link
Member

cosmos72 commented Apr 17, 2020

Looks good, thanks :)

To stream stdout/stderr to Jupyter, you need four things:

  1. get the stdout/stderr of the command as Go streams: you can use the methods Cmd.StdoutPipe() and Cmd.StderrPipe() of the struct os/exec.Cmd you are already using
  2. modify Kernel.handleExecuteRequest to create the two JupyterStreamWriter immediately - it currently creates them inside goroutines - and pass them to doEval() and further down to your evalShellCommand.
  3. a goroutine reading from Cmd.StdoutPipe() and writing into the first JupyterStreamWriter. You can copy and adapt the code in kernel.go, lines 406-411
  4. another goroutine, reading from Cmd.StderrPipe() and writing into the second JupyterStreamWriter. You can copy and adapt the code in kernel.go, lines 413-417

Note: be careful to wait for the command to exit and for the goroutines to finish before returning from evalShellCommand

@Oshuma
Copy link
Contributor Author

Oshuma commented Apr 21, 2020

@cosmos72 Sounds good. I'll implement that as soon as I get a chance and update this PR.

@Oshuma
Copy link
Contributor Author

Oshuma commented Apr 22, 2020

@cosmos72 Can you verify/merge when you get a chance?

@cosmos72 cosmos72 merged commit 29b2c79 into gopherdata:master Apr 22, 2020
@cosmos72
Copy link
Member

merged, with some little improvements.
Thanks!

@Oshuma Oshuma deleted the issue-196 branch April 23, 2020 05:57
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.

2 participants