Message5023

Author danny
Recipients danny
Date 2009-08-13.23:45:35
SpamBayes Score 4.781583e-08
Marked as misclassified No
Message-id <1250207137.0.0.335689662624.issue1433@psf.upfronthosting.co.za>
In-reply-to
Content
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
effect).

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 post.py 
Read this line from child: "Read this line from parent: 'Test line'"
Waiting 10 seconds
Exiting


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

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


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.

Cheers,
Danny



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)
    sys.stdout.flush()
else:
    pin,pout = os.popen2('/usr/bin/jython
/usr/local/sem/CampaignManager/src/test/Pipes/post.py --child')
    pin.write("Test line\n")
    pin.flush()
    #pin.close()
    print 'Read this line from child: "%s"' %pout.readline()
    print "Waiting 10 seconds"
    time.sleep(10)
    print "Exiting"
History
Date User Action Args
2009-08-13 23:45:37dannysetrecipients: + danny
2009-08-13 23:45:37dannysetmessageid: <1250207137.0.0.335689662624.issue1433@psf.upfronthosting.co.za>
2009-08-13 23:45:36dannylinkissue1433 messages
2009-08-13 23:45:35dannycreate