title: How can I use python's telnetlib to fetch data from a device for a fixed period of time?
body: <p>I'm connecting to a hardware device via telnet. That device is pretty simple in terms of I/O. So I submit a command to it, and after that the device pumps out data one line at a time, once per second. Each line just contains a number.</p>
  
  <p>So my question is this: if I connect to this device using python's telnetlib, how can I fetch data for a fixed period of time (or a fixed number of lines of data)?</p>
  
  <p>I've tried using all the various read_ commands, but they all seem to block indefinitely, apart from read_until, which I can't use as the output can't be used to determine when to stop.</p>
  
  <p>(I'm running python 2.5 under Cygwin, btw).</p>
  
  <p>Edit: Maybe the real question is, should I be using telnetlib at all for this, or should I just use the socket module?</p>