title: asyncio event loop equivalent with uvloop
body: <p>I have an event loop with coroutine method using <code>asyncio</code>.</p>
  
  <p>I enthusiast to looking for an equivalent of the following example using <a href="https://github.com/MagicStack/uvloop" rel="nofollow noreferrer">uvloop</a> instead.</p>
  
  <p>Here's a simple <code>asyncio</code> event loop example: </p>
  
  <pre><code>import asyncio
  
  async def read(**kwargs):
      oid = kwargs.get('oid', '0.0.0.0.0.0')
      time = kwargs.get('time', 1)
      try:
          print('start: ' + oid)
      except Exception as exc:
          print(exc)
      finally:
          await asyncio.sleep(time)
          print('terminate: ' + oid)
  
  
  def event_loop(configs):
      loop = asyncio.get_event_loop()
  
      for conf in configs:
          asyncio.ensure_future(read(oid=conf['oid'], time=conf['time']))
  
      return loop
  
  if __name__ == '__main__':
      snmp_configurations = [
          {'time': 5, 'oid': '1.3.6.3.2.4'},
          {'time': 6, 'oid': '1.3.6.3.5.8'},
      ]  # TODO :: DUMMY
      loop = event_loop(snmp_configurations)
      try:
          loop.run_forever()
      except KeyboardInterrupt:
          pass
      finally:
          print("Closing Loop")
          loop.close()
  </code></pre>
  
  <hr>
  
  <h1>Question:</h1>
  
  <ul>
  <li><p>How to reform the above snippet code by using <a href="https://github.com/MagicStack/uvloop" rel="nofollow noreferrer">uvloop</a>?</p></li>
  <li><p>Is the following change correct for using <a href="https://github.com/MagicStack/uvloop" rel="nofollow noreferrer">uvloop</a> with more performance?</p>
  
  <pre><code>import uvloop
  
  def event_loop(configs):
      asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())  # TODO  :: uvloop.
      loop = asyncio.get_event_loop()
  
   `   for conf in configs:
          asyncio.ensure_future(read(oid=conf['oid'], time=conf['time']))
  
      return loop
  </code></pre></li>
  </ul>
  
  <hr>
  
  <p>[<strong>NOTE</strong>]:</p>
  
  <ul>
  <li><a href="https://github.com/MagicStack/uvloop" rel="nofollow noreferrer">uvloop</a> claims that makes asyncio 2-4x faster.</li>
  </ul>