Wait for input, but only for a certain amount of time

Discussion in 'Python' started by Pif Paf, Feb 23, 2004.

  1. Pif Paf

    Pif Paf Guest

    I have a process, and my process wants to wait for input but only for
    a certain amount of time. The input might be coming from a Python file
    object (created with popen) or a TCP socket.

    What I want is something like:

    s = getTimedInput(source, maxDelay)

    where:
    source = the source of the input
    maxDelay = the maximum amount of time we're going to wait for input,
    in milliseconds. We wait this amount of time, or a shorter time if we
    receive a "\n"(1) in the character stream
    s = a string containing the input that was received


    (1): or whatever delimiter character we're using.

    --
    Pif Paf
    Pif Paf, Feb 23, 2004
    #1
    1. Advertising

  2. Pif Paf wrote:

    > I have a process, and my process wants to wait for input but only for
    > a certain amount of time. The input might be coming from a Python file
    > object (created with popen) or a TCP socket.
    >
    > What I want is something like:
    >
    > s = getTimedInput(source, maxDelay)
    >
    > where:
    > source = the source of the input
    > maxDelay = the maximum amount of time we're going to wait for input,
    > in milliseconds. We wait this amount of time, or a shorter time if we
    > receive a "\n"(1) in the character stream
    > s = a string containing the input that was received
    >
    >
    > (1): or whatever delimiter character we're using.
    >


    If it is a socket on any platform, use select.select().
    If it is a file in *nix, use select.select().
    If it is a file in windows, check pywin32 (http://sf.net/projects/pywin32)

    - Josiah
    Josiah Carlson, Feb 24, 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. Jack Wright
    Replies:
    2
    Views:
    6,918
    yeswanthi
    May 28, 2007
  2. Jim
    Replies:
    2
    Views:
    421
    bruce barker
    Jul 19, 2004
  3. Dave
    Replies:
    0
    Views:
    481
  4. Daniel Walzenbach
    Replies:
    3
    Views:
    115
    Jeffrey Tan[MSFT]
    Mar 4, 2004
  5. Eduard Witteveen

    No mousemovement for a certain amount of time

    Eduard Witteveen, Jul 7, 2005, in forum: Javascript
    Replies:
    4
    Views:
    113
    Eduard Witteveen
    Jul 8, 2005
Loading...

Share This Page