title: Asyncio coroutines
body: <p>I thought I had grokked coroutines with David Beazley's very good <a href="http://www.dabeaz.com/coroutines/" rel="nofollow">presentation</a> but I can't reconcile it fully with the new syntax described in <a href="https://www.python.org/dev/peps/pep-0492/" rel="nofollow">PEP-492</a>. </p>
  
  <p>In the presentation, he explains how coroutines can be thought of as a pipeline that gets pushed to as opposed to pulled from like in generators. </p>
  
  <p>For example:</p>
  
  <pre><code># cofollow.py
  #
  # A simple example showing how to hook up a pipeline with
  # coroutines.   To run this, you will need a log file.
  # Run the program logsim.py in the background to get a data
  # source.
  
  from coroutine import coroutine
  
  # A data source.  This is not a coroutine, but it sends
  # data into one (target)
  
  import time
  def follow(thefile, target):
      thefile.seek(0,2)      # Go to the end of the file
      while True:
           line = thefile.readline()
           if not line:
               time.sleep(0.1)    # Sleep briefly
               continue
           target.send(line)
  
  # A sink.  A coroutine that receives data
  
  @coroutine
  def printer():
      while True:
           line = (yield)
           print line,
  
  # Example use
  if __name__ == '__main__':
      f = open("access-log")
      follow(f,printer())
  </code></pre>
  
  <p>How can one implement the <code>printer()</code> coroutine using this new syntax? I have not yet seen an example where the coroutine gets pushed to using this new syntax. Is it possible?</p>