Buffer problem on SunOS

Discussion in 'Python' started by gaool, Nov 22, 2004.

  1. gaool

    gaool Guest

    Hello,

    I wrote a python script (python 2.3.3) to send some commands to a
    programm and to show on the screen the responses of this programm. I
    use "Pipedream.py" module in my script to speak with the programm
    (under unix system, it uses fdopen() to create a pipe and to send the
    specified string. fdopen has a buffer size argument).So I can specify
    a buffer size when I send a command with the pipedream module.

    On windows it works but on SunOS I have a buffer problem (may be it
    would be te same on other unix system...). I don't see the response of
    my program before the buffer (which buffer?) is full.

    I tried to put differents values for the buffer size argument of the
    Pipedream object:
    0 (which means unbuffered), 1 (line buffered), and other values (which
    create a buffer with the size of the specified value).

    But it's always the same thing: if the responses of the program are
    short, nothing append. I have to send a lot of commands to full the
    buffer. And then I can see all the responses of the commands I send
    before and the last response of the last send command.

    If the responses of the send command are big, it fill the buffer and I
    can see as much lines of the response as the buffer size. And I don't
    see the rest of my response.

    Apparently, it doesn't depend on the buffer size argument of Pipedream
    module.

    In fact, it seems that there is a SunOS buffer but I don't know its
    size and what I have to do to set it or to delete it.

    If you have any idea...

    Best regards.
     
    gaool, Nov 22, 2004
    #1
    1. Advertising

  2. gaool

    Donn Cave Guest

    In article <>,
    (gaool) wrote:
    ....
    > If the responses of the send command are big, it fill the buffer and I
    > can see as much lines of the response as the buffer size. And I don't
    > see the rest of my response.
    >
    > Apparently, it doesn't depend on the buffer size argument of Pipedream
    > module.
    >
    > In fact, it seems that there is a SunOS buffer but I don't know its
    > size and what I have to do to set it or to delete it.


    I'm not acquainted with this "Pipedream" module, but you may
    be interested to know that the UNIX operating system provides
    a system level read(2) function that does not buffer any input.
    If you apply this function to a pipe file descriptor, it will
    return with whatever data was in the pipe, or block if there
    is no data. That function is available in the posix module,
    a.k.a. os module.

    There's a pretty good chance however that it won't help, because
    the data is indeed sitting in a buffer on the other side of the
    pipe. That isn't a SunOS buffer per se, except inasmuch as it's
    provided by the C stdio library functions that your application
    probably calls for output. If it can be rewritten to flush its
    output regularly, that will help. Otherwise the only thing you
    can do is try to create a "pseudotty" instead of a pipe, because
    standard buffering policy changes to line buffered on a tty.
    There are modules for this, but you may find an openpty() function
    in the posix module that will work for your purposes. In any case
    this is not a simple solution, nor a cheap one in terms of system
    resources.

    Donn Cave,
     
    Donn Cave, Nov 22, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nishi Bhonsle
    Replies:
    17
    Views:
    958
    Nishi Bhonsle
    Sep 27, 2004
  2. Replies:
    2
    Views:
    1,788
    gaool
    Sep 16, 2004
  3. Ben Edwards
    Replies:
    0
    Views:
    143
    Ben Edwards
    Jun 14, 2007
  4. kielhd

    Performance problem on SunOS 5.8

    kielhd, Nov 24, 2003, in forum: Perl Misc
    Replies:
    5
    Views:
    161
    James Willmore
    Nov 26, 2003
  5. Iain
    Replies:
    0
    Views:
    125
Loading...

Share This Page