Title: Can't flush output to pipes like Python can
Type: behaviour Severity: major
Components: Core Versions: 2.5.0
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: cgroves, danny, fwierzbicki
Priority: Keywords:

Created on 2009-08-13.23:45:36 by danny, last changed 2009-08-25.08:02:01 by cgroves.

File name Uploaded Description Edit Remove
unnamed danny, 2009-08-17.21:54:16
msg5023 (view) Author: Danny Goodman (danny) Date: 2009-08-13.23:45:35
In Jython, it doesn't seem be possible to flush the buffer of a
'write'-mode pipe on request the way Python does (pipe.flush() has no

At bottom is a simple program to create a pipe, write to it, read from
it, and close.  The behavior in Python is as expected: 

$ python 
Read this line from child: "Read this line from parent: 'Test line'"
Waiting 10 seconds

In Jython, though, the program hangs until quit forcibly:

$ jython
Traceback (most recent call last):
  File "/usr/local/sem/CampaignManager/src/test/Pipes/", line 6, in ?
    line = sys.stdin.readline()[:-1]

If I close the pipe, instead of just flushing, though, the behavior is
correct, which leads me to think that 'flush()' is being ignored.  This
is important for being able to use pipes.


import os
import sys
import time

if len(sys.argv) > 1: # Child
    line = sys.stdin.readline()[:-1]
    sys.stdout.write("Read this line from parent: '%s'" %line)
    pin,pout = os.popen2('/usr/bin/jython
/usr/local/sem/CampaignManager/src/test/Pipes/ --child')
    pin.write("Test line\n")
    print 'Read this line from child: "%s"' %pout.readline()
    print "Waiting 10 seconds"
    print "Exiting"
msg5052 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-08-17.21:32:52
What operating system are you on?  On my local OSX I seem to get the
same behavior from python and jython.
msg5053 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-08-17.21:38:51
oops, scratch that, I failed to port the script over to my system well
enough.  I was able to reproduce the hang.
msg5054 (view) Author: Danny Goodman (danny) Date: 2009-08-17.21:54:16
Thanks Frank.  FYI here's my os info in case it's helpful:
Linux yoda 2.6.18-128.el5 #1 SMP Wed Jan 21 10:41:14 EST 2009 x86_64 x86_64
x86_64 GNU/Linux

On Mon, Aug 17, 2009 at 2:38 PM, Frank Wierzbicki <>wrote:

> Frank Wierzbicki <> added the comment:
> oops, scratch that, I failed to port the script over to my system well
> enough.  I was able to reproduce the hang.
> _______________________________________
> Jython tracker <>
> <>
> _______________________________________
msg5064 (view) Author: Charlie Groves (cgroves) Date: 2009-08-25.08:02:00
Should be fixed as of r6718.  Thanks for the report!
Date User Action Args
2009-08-25 08:02:01cgrovessetstatus: open -> closed
resolution: fixed
messages: + msg5064
nosy: + cgroves
2009-08-17 21:54:17dannysetfiles: + unnamed
messages: + msg5054
2009-08-17 21:38:51fwierzbickisetmessages: + msg5053
2009-08-17 21:32:52fwierzbickisetnosy: + fwierzbicki
messages: + msg5052
2009-08-13 23:45:36dannycreate