select.select() on windows

Discussion in 'Python' started by jas, Oct 25, 2005.

  1. jas

    jas Guest

    I am currently using subprocess to execute a command. Then I read from
    it's stdout...however, this is hanging on a read..waiting for more
    bytes. So what I would like is to timeout...and select.selec() seems
    to be what I need. Except I don't have a socket, i have stdout.

    Any suggestions on how to do a timeout like select.select with stdout?

    Thanks
    jas, Oct 25, 2005
    #1
    1. Advertising

  2. you have to use non-block readining.

    http://docs.python.org/lib/module-select.html:
    A time-out value of zero specifies a poll and never blocks.

    jas wrote:
    > I am currently using subprocess to execute a command. Then I read from
    > it's stdout...however, this is hanging on a read..waiting for more
    > bytes. So what I would like is to timeout...and select.selec() seems
    > to be what I need. Except I don't have a socket, i have stdout.
    >
    > Any suggestions on how to do a timeout like select.select with stdout?
    >
    > Thanks
    >



    --
    Best regards,
    Maksim Kasimov
    mailto:
    Maksim Kasimov, Oct 26, 2005
    #2
    1. Advertising

  3. jas

    Ben Sizer Guest

    jas wrote:
    > I am currently using subprocess to execute a command. Then I read from
    > it's stdout...however, this is hanging on a read..waiting for more
    > bytes. So what I would like is to timeout...and select.selec() seems
    > to be what I need. Except I don't have a socket, i have stdout.
    >
    > Any suggestions on how to do a timeout like select.select with stdout?


    I am not too familiar with any asynchronous I/O facilities in Python
    beyond select, so in your situation I would use the threading module,
    with the blocking read in one thread and your time-out in the main
    thread. You could perhaps use an Event object here, which has the
    time-out functionality for you.

    --
    Ben Sizer
    Ben Sizer, Oct 26, 2005
    #3
  4. On Wed, 26 Oct 2005 11:29:17 +0300, Maksim Kasimov
    <> declaimed the following in comp.lang.python:

    >
    > you have to use non-block readining.
    >
    > http://docs.python.org/lib/module-select.html:
    > A time-out value of zero specifies a poll and never blocks.
    >

    Did you miss the subject line... "... on windows"? select() only
    works with sockets on windows, not on regular file streams.
    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
    Dennis Lee Bieber, Oct 26, 2005
    #4
  5. yes, i missed, sorry

    Dennis Lee Bieber wrote:
    > On Wed, 26 Oct 2005 11:29:17 +0300, Maksim Kasimov
    > <> declaimed the following in comp.lang.python:
    >
    >
    >>you have to use non-block readining.
    >>
    >>http://docs.python.org/lib/module-select.html:
    >>A time-out value of zero specifies a poll and never blocks.
    >>

    >
    > Did you miss the subject line... "... on windows"? select() only
    > works with sockets on windows, not on regular file streams.



    --
    Best regards,
    Maksim Kasimov
    mailto:
    Maksim Kasimov, Oct 27, 2005
    #5
    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. =?Utf-8?B?RGFiYmxlcg==?=

    select gridview row without using select button?

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 3, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    101,516
    dch31969
    Feb 27, 2009
  2. J. Hall
    Replies:
    2
    Views:
    1,058
    Jeff Thies
    Apr 21, 2004
  3. Laszlo Nagy

    select.select and socket.setblocking

    Laszlo Nagy, Dec 30, 2008, in forum: Python
    Replies:
    12
    Views:
    1,177
    Roy Smith
    Jan 3, 2009
  4. Paul  Moore
    Replies:
    16
    Views:
    1,767
    Paul Kölle
    May 9, 2010
  5. palmiere
    Replies:
    1
    Views:
    396
    Erwin Moller
    Feb 9, 2004
Loading...

Share This Page