title: What is the best way to read files in an EventMachine-based app?
body: <p>In order not to block the reactor I would like to read files asynchronously, but I've found no obvious way of doing it using EventMachine. I've tried a few different approaches, but none of them feels right:</p>
  
  <ul>
  <li>Just read the file, it'll block the reactor, but what the hell, it's not <em>that</em> slow (unless it's a big file, and then it definitely is).</li>
  <li>Open the file for reading and read a chunk on each tick (but how much to read? too much and it'll block the reactor, too little and reading will get slower than necessary).</li>
  <li><code>EM.popen('cat some/file', FileReader)</code> feels really weird, but works better than the alternatives above. In combination with the <code>LineAndTextProtocol</code> it reads lines pretty swiftly.</li>
  <li><code>EM.attach</code>, but I haven't found any examples of how to use it, and the only thing I've found on the mailing list is that it's deprecated in favour of…</li>
  <li><code>EM.watch</code>, which I've found no examples of how to use for reading files.</li>
  </ul>
  
  <p>How do you read files within a EventMachine reactor loop?</p>