Non blocking read from stdin on windows.

Discussion in 'Python' started by barr, Dec 25, 2004.

  1. barr

    barr Guest

    Hi
    Can any one help.

    I am trying to write a python scipt that takes input as args and/or as piped
    input ( possibly the output of another program).

    I want to read stdin ( the piped in stuuff ) whcih might be empty without
    the script blocking if it is empty.

    I understand it is possible to do under unix with the select call. Can some
    one please explain how to do this in windows.

    thanks in advance.

    Barr
    barr, Dec 25, 2004
    #1
    1. Advertising

  2. barr

    Noam Raphael Guest

    You can always have a thread which continually reads stdin and stores it
    in a string, or better, in a cStringIO.StringIO object. Then in the main
    thread, you can check whether something new has arrived. This, of course
    will work on all platforms.

    I hope this helped a bit,
    Noam
    Noam Raphael, Dec 25, 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. Hendra Gunawan
    Replies:
    1
    Views:
    12,518
    Allan Herriman
    Apr 8, 2004
  2. Andre Kelmanson

    blocking i/o vs. non blocking i/o (performance)

    Andre Kelmanson, Oct 10, 2003, in forum: C Programming
    Replies:
    3
    Views:
    922
    Valentin Tihomirov
    Oct 12, 2003
  3. Jeff Learman

    blocking read on stdin on Windows?

    Jeff Learman, Sep 4, 2004, in forum: Python
    Replies:
    5
    Views:
    712
    Jeff Learman
    Sep 5, 2004
  4. barr
    Replies:
    3
    Views:
    1,119
    Miki Tebeka
    Dec 28, 2004
  5. Serge Savoie
    Replies:
    4
    Views:
    263
    Serge Savoie
    Oct 1, 2008
Loading...

Share This Page