title: How do I avoid the loop argument
body: <p>The following code is part of some automated tests that I have written in python 3.6:</p>
  
  <pre><code>connected = False
  
  def aiohttp_server(loop):
      async def handler(msg, session):
          global connected
          if msg.type == sockjs.MSG_OPEN:
              connected = True
          if msg.type == sockjs.MSG_CLOSE:
              connected = False
  
      app = web.Application(loop=loop)
      sockjs.add_endpoint(app, handler)
      runner = web.AppRunner(app)
      return runner
  
  def run_server(runner, loop):
      logging.basicConfig(level=logging.DEBUG,
                          format='%(asctime)s %(levelname)s %(message)s')
  
      asyncio.set_event_loop(loop)
      loop.run_until_complete(runner.setup())
      site = web.TCPSite(runner, 'localhost', 8080)
      loop.run_until_complete(site.start())
      loop.run_forever()
  
  def start_server():
      loop = asyncio.new_event_loop()
      t = threading.Thread(target=run_server, args=(aiohttp_server(loop),loop,), daemon=True)
      t.start()
      time.sleep(0.01)
  </code></pre>
  
  <p>Basically, calling start_server should initiate a simple web server with a sockjs endpoint named <code>/sockjs</code></p>
  
  <p>I am not yet a master of python's <code>async</code> keyword. There are two issues, that I suspect are related:</p>
  
  <p>Firstly, I am getting a deprecation warning on the <code>app = web.Application(loop=loop)</code> statement:</p>
  
  <pre><code>/home/peter/incubator/sockjs_client/tests/test_sockjs_client.py:25: DeprecationWarning: loop argument is deprecated
    app = web.Application(loop=loop)
  /home/peter/.local/lib/python3.6/site-packages/sockjs/route.py:54: DeprecationWarning: loop property is deprecated
    manager = SessionManager(name, app, handler, app.loop)
  </code></pre>
  
  <p>And secondly, the tests fail occasionally. I believe that, depending on machine load, sometimes the server hasn't had enough time to start before the test code actually starts executing.</p>
  
  <p>Basically, what I need is for the <code>start_server</code> function to initialise a web application with a websocket endpoint, and not return until the application is prepared to accept websocket connections.</p>