bash_kernel icon indicating copy to clipboard operation
bash_kernel copied to clipboard

Broken Pipe Errors

Open cledoux opened this issue 10 years ago • 8 comments

Using any type of non-trivial pipe prints a "Broken pipe" error.

For example, use the following code snippet: < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;

Executing in bash behaves as expected:

< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
3JT1JUE_NE8-CcgaJXfkESNfWLgiVIWd

Executing in ipython (notebook or console both give same error):

In [1]: < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo;
QgmPQRyp0u1Lllf6c4Y5mAE8FxM563A_tr: write error: Broken pipe
tr: write error

cledoux avatar Mar 09 '15 23:03 cledoux

same errors here: image

I do get the results I need but the errors are somewhat annoying :)

RemiSlv avatar Apr 14 '16 08:04 RemiSlv

I can reproduce it, but I have no idea what's going on with this.

takluyver avatar Apr 14 '16 11:04 takluyver

looks like this should help: https://docs.python.org/2/library/subprocess.html#replacing-shell-pipeline

although that will probably be a pain to manage nested commands such as echo $(ls | grep something) | grep something

RemiSlv avatar Apr 14 '16 14:04 RemiSlv

The bash_kernel is not emulating bash in Python: it's actually running a bash shell in a separate process and sending your code to that.

takluyver avatar Apr 14 '16 14:04 takluyver

image

So i'm getting the same error as well, https://blog.nelhage.com/2010/02/a-very-subtle-bug/ is this what's causing it?

dborgesr avatar May 13 '17 16:05 dborgesr

Aha, good find. I think that might well be it. Would you like to make a PR? pexpect's spawn() now takes a preexec_fn like subprocess.

takluyver avatar May 15 '17 15:05 takluyver

I'm getting odd broken pipe errors too. Is this issue still open or could it be something new?

pgcudahy avatar Dec 28 '18 09:12 pgcudahy

I'm also getting this issue with zcat

pierrepo avatar Mar 22 '23 15:03 pierrepo