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

Pif Paf p1fp4f at hotmail.com
Mon Feb 23 12:43:01 EST 2004


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



More information about the Python-list mailing list